Skip to main content

lazyRange()

lazyRange(start, end?, step?): Iterable<number>

Creates a lazy numeric range.

Supports both ascending and descending ranges, as well as infinite ranges (use take to bound them).


Parameters​

start: number​

Start value (inclusive)

end?: number = Infinity​

End value (exclusive), defaults to Infinity

step?: number = 1​

Step increment, defaults to 1


Returns: Iterable<number>​

A lazy Iterable of numbers


Since​

2.4.0


Example​

toArray(lazyRange(0, 5));       // [0, 1, 2, 3, 4]
toArray(lazyRange(0, 10, 3)); // [0, 3, 6, 9]
toArray(lazyRange(5, 0, -1)); // [5, 4, 3, 2, 1]