Essentially, I’d like to do the following as a one-liner:
int sum = initialValue;
for (int n : collectionOfInts) {
sum += n;
}
return sum;
I see that there’s http://functionaljava.org/examples/1.5/#Array.foldLeft, but I’d rather not have to copy the collection.
If you use the foldLeft from IterableW instead of Array, you won’t have to copy anything.