"fold": a replacement for "reduce"

monarch_dodra monarchdodra at gmail.com
Tue Mar 25 14:32:07 PDT 2014


On Tuesday, 25 March 2014 at 21:27:45 UTC, Nordlöw wrote:
>> Actually, not with a trivial use case.
>>
>> I think I'm over-engineering.
>
> Do you have a sample implementation on Github I can test?
>
> /Per

You can test my re-implementation of fold/reduce here if you want:
https://github.com/D-Programming-Language/phobos/pull/2033

It contains code that tests the "stability" thing I was talking 
about, but I think I'm going to remove it.
https://github.com/D-Programming-Language/phobos/pull/2033/files#diff-ff74a46362b5953e8c88120e2490f839R992

I think it's better to simply require that:
give: alias S = typeof(r.front, r.front);
isAssignable!(S, typeof(fun(S.init, r.front))


More information about the Digitalmars-d mailing list