sum return type for primitive streams
alahijani at gmail.com
Fri Feb 1 09:23:55 PST 2013
On Fri, Feb 1, 2013 at 8:18 PM, Brian Goetz <brian.goetz at oracle.com> wrote:
> 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.
You're right, we usually view int and long as approximations of
mathematical integers, which have no top/bottom elements. So main/max on
pure infinite integers (BigIntegers) do not have an identity.
One could argue that when you are using an IntStream or LongStream instead
of a Steam<BigIntegers>, you have already decided that you only need a
finite subset of mathematical integers, so you should be prepared to see
MIN_VALUE and MAX_VALUE used as positive/negative infinity. But I don't see
that argument persuading anyone.
So, in such an imperfect world, I guess there is no better answer for this
More information about the lambda-dev