IntStreams and the case of the missing reduce

Brent Walker brenthwalker at
Tue Jan 7 16:12:15 PST 2014

There is no asymmetry in my suggestion.  Please read my first email again
-- I was raising 2 issues: (a) The missing reduce() from the primitive
streams, and (b) A missing foldLeft() like function for streams (sequential
by nature).

We have discussed (a) long enough and agreed to disagree so no more on that.

I assume you are talking about (b) and the implementation I gave, when you
call say I introduced an asymmetry.  Let me quote what I said in my first

"You could perhaps have a version of reduce without the combiner so that we
can avoid this code-smell in most uses of reduce -- if the stream happened
to be parallel, then make do without the combiner --* do things
sequentially for example*."

In the code I gave I throw an exception for parallel streams (instead of
doing things sequentially) because it was the quick and easy thing to do
for someone sitting outside the internals of stream code -- I wouldn't want
it done that way in a jdk api and I never suggested it.  To do things
properly from the outside I would have to collect a parallel stream into a
container and then make a sequential stream out of that -- too much code
for me to write when I know that I am only calling those functions on
sequential streams.  But the JDK would of course have to deal with parallel


On Tue, Jan 7, 2014 at 9:55 PM, Richard Warburton <
richard.warburton at> wrote:

> Hi,
> I guess I am slightly worked up over this because reduce() is so
>> fundamental to functional programming and because it comes up so often when
>> doing anything really, that I hate to see it curtailed like this.  Also I
>> am not a big fun of assymetrys in APIs.
> I'm sure we can all sympathise these kind of things, not everyone agrees
> on the perfect API.
> One thing I will observe from reading this thread is that you argued
> against the asymmetry in the public API, you haven't looked at the
> asymmetry that you've introduced yourself. You have an implementation
> that's sequential only which means you've got an asymmetry between the
> parallel and serial versions of the API. Is that better or worse?
> regards,
>   Richard Warburton
>   @RichardWarburto <>

More information about the lambda-dev mailing list