ints(), longs(), doubles() <was> Re: Ranges
Howard Lovatt
howard.lovatt at gmail.com
Sat May 4 06:36:41 PDT 2013
Yes I use it to iterate over indexes mainly; as a direct replacement for a for loop, with the body of the loop as the argument to forEach.
If you need an inclusive range then you can use the whileTrue form with (i) -> i <= inclusiveEnd; provided inclusiveEnd isn't MAX_VAL, in which case && i >= from also needed.
For reverse loops I do:
from(array.length - 1).whileTrue((i) -> i >= 0).step(-1).stream()...
IE it is up to the programmer to get the limits right and consistent with step, I don't check the values because I don't know them for the generalised forms of to (whileTrue) and step (with lambda argument).
-- Howard.
Sent from my iPad
On 04/05/2013, at 1:42 PM, John Rose <john.r.rose at oracle.com> wrote:
> On May 3, 2013, at 8:30 PM, John Rose <john.r.rose at oracle.com> wrote:
>
>> Do you use the API mainly for array (or list or vector) index generation
>
> P.S. Also, what does it look like when you need to iterate over an array in reverse order?
More information about the lambda-dev
mailing list