reduce -> fold?

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Wed Feb 3 13:45:04 PST 2016


On 02/03/2016 09:12 PM, Atila Neves wrote:
>
> https://github.com/D-Programming-Language/phobos/pull/3968
>
> I think fold should be nothrow, but maybe that's just me. It's also a
> massive pain to make it that way, so I didn't for now.

Returning Unqual!(ElementType!R).init makes no sense though.
The "correct" result of fold!f([]) is a (often, the) value 'a' such that 
for any 'b', 'f(a,b)==b' (which is the canonical choice of "seed"), but 
there is no way for fold to infer such a value.


More information about the Digitalmars-d mailing list