[Issue 12655] foldRange
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Jul 4 04:07:51 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=12655
--- Comment #3 from jens.k.mueller at gmx.de ---
A cumulate returning the same number elements can be written using map.
auto cumulate(alias f, R, T)(R r, T seed)
if (isInputRange!R && is(T == ElementType!R))
{
import std.algorithm : map;
return r.map!(a => a = seed = f(seed, a));
}
I leave this here for reference and others to decide whether such a function
should be added to Phobos.
--
More information about the Digitalmars-d-bugs
mailing list