sum of numbers using Primitives range
Brian Goetz
brian.goetz at oracle.com
Tue Dec 11 17:55:24 PST 2012
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 = 45. Ranges are half-open. As in,
for (int i=0; i<10; i++) { ... }
On 12/11/2012 8:46 PM, Arul Dhesiaseelan wrote:
> Sum of integers over using a Primitives range returns invalid result.
>
> range(1, 10).map(operand -> operand).sum();
> range(1, 10).reduce(0, Integer::sum);
> range(1, 10).sum();
>
>
> They all yield 45, instead of 55. Is this a bug?
>
> -Arul
>
More information about the lambda-dev
mailing list