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

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


On Feb 23 2011, at 11:54 , lambda-dev-request at openjdk.java.net wrote:

> From: Neal Gafter <neal at gafter.com>
> Date: February 23, 2011 07:49:49 PST
> To: brian.goetz at oracle.com
> Cc: lambda-dev at openjdk.java.net
> 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?

Mike


More information about the lambda-dev mailing list