liittle question about reduce
Timon Gehr
timon.gehr at gmx.ch
Sat Sep 29 16:07:57 PDT 2012
On 09/30/2012 01:04 AM, bioinfornatics wrote:
> hi,
>
>
> int[] list = [ 0, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9 ];
>
> why this do not works ?
> list.reduce!( (a,b) => a + b )( 0 ); // sum all elements
>
> but by this way that is ok:
> reduce!( (a,b) => a + b )( 0, list ); // sum all elements
>
>
Because of the parameter order.
0.reduce!((a,b)=>a+b)(list); // works
More information about the Digitalmars-d-learn
mailing list