reduce -> fold?

Dragos Carp via Digitalmars-d digitalmars-d at puremagic.com
Mon Feb 1 00:46:50 PST 2016


On Friday, 29 January 2016 at 20:40:18 UTC, Andrei Alexandrescu 
wrote:
> That'd be interesting if (a) lazy and (b) general a la 
> https://dlang.org/library/std/range/recurrence.html. -- Andrei

To be clear, by general you mean to allow functions with more 
than 2 arguments?

For example if you have:

foo(int i, int j, int k) { return i + j + k; }

then:

scan!foo([1, 2, 3, 4]).array returns [1, 2, 6, 12]

Is "scan" (thanks Timon) telling enough? The python "accumulate" 
conflicts with the C++ meaning.



More information about the Digitalmars-d mailing list