reduce -> fold?

John Colvin via Digitalmars-d digitalmars-d at puremagic.com
Thu Feb 4 06:45:49 PST 2016


On Friday, 29 January 2016 at 20:40:18 UTC, Andrei Alexandrescu 
wrote:
> On 01/29/2016 08:56 AM, Dragos Carp wrote:
>> On Friday, 29 January 2016 at 13:11:34 UTC, Luís Marques wrote:
>>> [...]
>>
>> 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

I wrote a bit about this sort of thing here: 
https://github.com/D-Programming-Language/phobos/pull/2991#issuecomment-141816906


More information about the Digitalmars-d mailing list