Ranges redux

Paul Sandoz paul.sandoz at oracle.com
Mon May 13 03:30:08 PDT 2013

On May 8, 2013, at 9:05 PM, Paul Sandoz <Paul.Sandoz at oracle.com> wrote:

> Hi,
> I think we reached consensus on:
> - {Int, Long}String.range/rangeClosed for step of 1
> IMO that seems good enough, and we can provide examples using map for step > 1 and descending ranges.

In the lambda repo:


IntStream.ints() and LongStream.longs() are also included. 

Bikeshed opportunity? the static method LongStream.longs() could be confusing with the method IntStream.longs() for widening from ints to longs.

> We have still to converge on DoubleStream.range, which might suggest no strong opinions or we lack the use-cases. There are some tricky edge-cases to deal with. I am very close to proposing we drop it...

Perhaps a strong sign of whether we keep this or not is whether we can agree about the upper bound and half-open/closed ranges.

Sequentially DoubleStream.range is currently equivalent to the following:

     *     long size = (long) Math.ceil((startInclusive - endExclusive) / step);
     *     long i = 0
     *     for (double v = startInclusive; i < size; i++, v = startInclusive + step * i) {
     *         ...
     *     }

If startInclusive + step * size == endExclusive then the range could be closed, otherwise half-open. 

Is that a reasonable expectation?


More information about the lambda-libs-spec-observers mailing list