reduce -> fold?

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Fri Jan 29 12:40:18 PST 2016


On 01/29/2016 08:56 AM, Dragos Carp wrote:
> On Friday, 29 January 2016 at 13:11:34 UTC, Luís Marques wrote:
>> Just to bikeshed a little, I remember that when I first started using
>> std.algorithm I was ctrl-F'ing for "accumulate" and not finding it
>> quite often. D competes with C++ directly, so do consider that name :-)
>
> But not in python, where "accumulate"[1] is the generic equivalent of
> C++ "partial_sum"[2]. I like "fold" more.
>
> BTW this week, a colleague of mine implemented a python "accumulate" in
> D. Is there any interest to contribute it to Phobos? How should this be
> named?
>
> [1] https://docs.python.org/3/library/itertools.html#itertools.accumulate
> [2] http://en.cppreference.com/w/cpp/algorithm/partial_sum

That'd be interesting if (a) lazy and (b) general a la 
https://dlang.org/library/std/range/recurrence.html. -- Andrei



More information about the Digitalmars-d mailing list