Updated State of the Lambda
Howard Lovatt
howard.lovatt at gmail.com
Mon Dec 12 16:59:49 PST 2011
I agree that map is not a good fit for Java. In my own
parallel processing library I use:
retain/recycle/reduce
I like the alliteration as it is easy to remember and in addition to map
been a problem I have not used filter since it is not clear if filter(true)
rejects all or accepts all. Although I did use reduce I can see how people
would prefer combine, I was won over by the alliteration!
On 13 December 2011 06:23, Gernot Neppert <mcnepp02 at googlemail.com> wrote:
> Am 12.12.2011 12:21, schrieb Stephen Colebourne:
> > int sum = list.map(e -> e.size()).reduce(0, (a, b) -> a+b);
> >
> > I continue to be concerned about the verbs being used and their
> > readability. Clearly these terms are used elsewhere, but I continue to
> > be of the opinion that "map" is the wrong verb for Java, because of
> > Java.util.Map. My preference currently remains as
> > "transform/Transformer". Similarly, I think "combine" may be a better
> > verb than "reduce". With altered verbs, I think the mental shift
> > required is lessened:
> >
> > int sum = list.transform(e -> e.size()).combine(0, (a, b) -> a+b);
>
> I endorse your suggestion. I'd also prefer "transform", mainly because I
> tend to connect the verb "map" mentally with an operation such as the
> following:
>
> interface Collection<E> {
> ....
>
> public <K,M extends Map<? super K,? super E> M map(Function<? super E,?
> extends K> mapper, M target);
>
>
--
-- Howard.
More information about the lambda-dev
mailing list