Re: enumerate, and some improvements

2014-09-27 Thread bearophile via Digitalmars-d
-- And I'd like map/filter to accept arrays and associative arrays, and not just functions: void main() { import std.algorithm: map; auto keys = [1, 2, 1, 1, 1]; auto a = [0, 10, 20]; auto r1 = map!(k => a[k])(keys); // OK auto r2 = map!a(keys); // Error a

enumerate, and some improvements

2014-09-24 Thread bearophile via Digitalmars-d
Jakob Ovrum and others have added an enumerate() function to Phobos: https://issues.dlang.org/show_bug.cgi?id=5550 https://github.com/D-Programming-Language/phobos/pull/1866 A problem with enumerate() (present in other ranges too): void main() { import std.stdio, std.range; auto A = [0, 0