Can't chain reduce(seed, range)

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Aug 30 22:32:23 PDT 2015


On Monday, August 31, 2015 01:31:58 Yuxuan Shui via Digitalmars-d-learn wrote:
> Why is reduce defined as 'auto reduce(S, R)(S seed, R r)',
> instead of reduce(R r, S seed)? I can't chain it.
>
> Maybe provide both?

The reasons why the seed is first are historical. It predates UFCS being
added to the language, so there was no reason to put the range first when
when it was added to Phobos. I believe that there have been attempts to fix
it, but AFAIK, they ran into too many problems to be able to do it without
breaking existing code.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list