sum return type for primitive streams
Brian Goetz
brian.goetz at oracle.com
Fri Feb 1 08:48:41 PST 2013
> Sorry to bring it up again, but integers also form a monoid under min, max.
> With Integer.MIN_VALUE and Integer.MAX_VALUE being the obvious identities.
And what about longs? Having the same operation with different
identities for coincident sets is pretty confusing.
> This is absolutely no different from sum (at least in principle).
> We are unable to distinguish between the result of summing no elements
> and summing a list that happened to contain only zeros.
Except that the sum of no elements can reasonably be considered to be
zero, so the ambiguity is largely academic. The minimum value of an
empty set is NOT Integer.MAX_VALUE under any reasonable view of reality.
More information about the lambda-dev
mailing list