Using reduce() with tuples created by zip()

Craig Dillabaugh cdillaba at cg.scs.carleton.ca
Sat Nov 2 16:27:19 PDT 2013


On Friday, 1 November 2013 at 20:08:15 UTC, Philippe Sigaud wrote:
> What I'm trying to explain is that reduce takes two arguments: 
> the growing
> value and the current front. In your case, the current front is 
> indeed a
> 2-tuple, but that's an unrelated issue.
>
> You're trying to get:
>
> reduce!( (firstElemOfPair, secondElemOfPair) => ...) (range)
>
> to work, whereas reduce signature is:
>
> reduce!( (onGoingValue, elem) => ...) (range)

OK, NOW I understand what you were trying to point out. The
function has to take the running sum (in my case) as one of the
arguments.

Thanks for your patience.


More information about the Digitalmars-d-learn mailing list