import { range } from "https://deno.land/x/itertools@v1.1.2/builtins.ts";
Returns an iterator producing all the numbers in the given range one by one,
starting from start
(default 0), as long as i < stop
, in increments of
step
(default 1).
range(a)
is a convenient shorthand for range(0, a)
.
Various valid invocations:
range(5) // [0, 1, 2, 3, 4]
range(2, 5) // [2, 3, 4]
range(0, 5, 2) // [0, 2, 4]
range(5, 0, -1) // [5, 4, 3, 2, 1]
range(-3) // []
For a positive step
, the iterator will keep producing values n
as long
as the stop condition n < stop
is satisfied.
For a negative step
, the iterator will keep producing values n
as long
as the stop condition n > stop
is satisfied.
The produced range will be empty if the first value to produce already does not meet the value constraint.