Thread overview | |||||
---|---|---|---|---|---|
|
August 31, 2015 Can't chain reduce(seed, range) | ||||
---|---|---|---|---|
| ||||
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? |
August 31, 2015 Re: Can't chain reduce(seed, range) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Yuxuan Shui | 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
|
August 31, 2015 Re: Can't chain reduce(seed, range) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Yuxuan Shui | On Monday, 31 August 2015 at 01:32:01 UTC, Yuxuan Shui 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? You might be interested in this PR https://github.com/D-Programming-Language/phobos/pull/1955 It's a bit old, left a ping to see what's up. |
Copyright © 1999-2021 by the D Language Foundation