lambda-dev Digest, Vol 15, Issue 20 [reduce method result type]

Mike Duigou mike.duigou at
Mon Mar 7 15:57:47 PST 2011

On Feb 23 2011, at 11:54 , lambda-dev-request at wrote:

> From: Neal Gafter <neal at>
> Date: February 23, 2011 07:49:49 PST
> To: brian.goetz at
> Cc: lambda-dev at
> Subject: Re: hg: lambda/collections/jdk: 2 new changesets
> Brian-
> The "reduce" (left fold) method should not require the result type to be the
> same as the collection's element type.
> Cheers,
> Neal

Hi Neal;

That was my reaction as well but Brian convinced me that having a different result and initial type was just a conflation of map with reduce. After thinking about it for a while I've been unable to come up with any cases that couldn't be satisfied by a map step (which may merely do type conversion) before the reduce step. Is there another reason to have reduce return a different type than the element?


More information about the lambda-dev mailing list