import { range } from "https://deno.land/x/iter@v3.2.3/lib/generators.ts";
Creates an iterable over an inclusive range of numbers.
Examples
Example 1
Example 1
import * as iter from "https://deno.land/x/iter/mod.ts";
const range1 = iter.create.range(5);
console.log(...range1); // -> 0 1 2 3 4 5
const range2 = iter.create.range(11,16);
console.log(...range2); // -> 11 12 13 14 15 16
const range3 = iter.create.range(14,24,2);
console.log(...range3); // -> 14 16 18 20 22 24
const range4 = iter.create.range(12, 2, 2);
console.log(...range4); // -> 12 10 8 6 4 2
Parameters
- If no other arguments are provided, the range will go
from 0 until
endOrRangeStart
. Otherwise, this acts as the start of the range. To stress, this is inclusive, in contrast to Python'srange()
iterables.
Returns
IterableCircular<number>
An iterable over the range.