import { range } from "https://deno.land/x/aitertools@0.6.0/src/range.ts";
Creates a Range of numbers from 0 to stop
with step 1.
import { range } from "./range.ts";
for (const value of range(4)) console.log(value);
The above example will print the following 4 lines:
0
1
2
3
Note that the type of the range is Range<number>
, which implements
both Iterable<number>
and AsyncIterable<number>
.
Creates a Range of bigints from 0 to stop
with step 1.
import { range } from "./range.ts";
for (const value of range(4n)) console.log(value);
The above example will print the following 4 lines:
0
1
2
3
Note that the type of the range is Range<bigint>
, which implements
both Iterable<bigint>
and AsyncIterable<bigint>
.
Creates a Range of numbers with step 1.
import { range } from "./range.ts";
for (const value of range(2, 5)) console.log(value);
The above example will print the following 3 lines:
2
3
4
Note that the type of the range is Range<number>
, which implements
both Iterable<number>
and AsyncIterable<number>
.
Creates a Range of bigints with step 1.
import { range } from "./range.ts";
for (const value of range(2n, 5n)) console.log(value);
The above example will print the following 3 lines:
2
3
4
Note that the type of the range is Range<bigint>
, which implements
both Iterable<bigint>
and AsyncIterable<bigint>
.
Creates a Range of numbers.
import { range } from "./range.ts";
for (const value of range(10, -10, -3.5)) console.log(value);
The above example will print the following 6 lines:
10
6.5
3
-0.5
-4
-7.5
Note that the type of the range is Range<number>
, which implements
both Iterable<number>
and AsyncIterable<number>
.
Creates a Range of bigints.
import { range } from "./range.ts";
for (const value of range(10n, -10n, -5n)) console.log(value);
The above example will print the following 4 lines:
10
5
0
-5
Note that the type of the range is Range<bigint>
, which implements
both Iterable<bigint>
and AsyncIterable<bigint>
.