reduce -> fold?
Walter Bright via Digitalmars-d
digitalmars-d at puremagic.com
Fri Jan 29 10:41:46 PST 2016
On 1/29/2016 4:08 AM, Andrei Alexandrescu wrote:
> As has been discussed before there's been discussion about std.algorithm.reduce
> taking the "wrong" order of arguments (its definition predates UFCS). I recall
> the conclusion was there'd be subtle ambiguities if we worked reduce to
> implement both orders.
>
> So the next best solution is to introduce a new name such as the popular "fold",
> and put them together in the documentation.
>
>
> Thoughts?
>
> Andrei
Haskell can provide us with good inspiration and background for designing 'fold':
https://wiki.haskell.org/Fold
Note there is a foldl, foldr, and some more obscure foldt, foldi, and some others.
Another design point is should fold be lazy? I.e.
auto x = [1,2,3].fold!dg;
means that x is a function that will actually do the computation if called.
More information about the Digitalmars-d
mailing list