Question about Iterable.reduce signature

Brian Goetz brian.goetz at oracle.com
Tue May 22 07:19:41 PDT 2012


> Do I understand right?
> Point of 'reduce' accepts (T,T)->T is to have same signature
> T reduce(T base, Operator<T> reducer)
> in unrelated hierarchies of Iterable and Splittable
> instead of separate
> <U> U reduce((T, U)->U onNode, U onEnd) for sequential Iterable
> (should it be Sequence than?)

I believe you understand it correctly.  We are, at least for the time being, holding to the goal of having the same set of method names/signatures on both sequential and parallel streams.  It is possible we'll be forced off this at some point, but we're going to try not to fall off without good reason.  

There are a number of variants of reduce/fold that may be desirable, such as one that doesn't require a base value and throws when the stream is empty.  Those are in the "small fish" category for now, but we'll circle back around to whether we have the right set of reduce/fold methods at some point.  




More information about the lambda-dev mailing list