The start of the range (inclusive).
The end of the range (exclusive).
The steps of the numbers. Defaults to 1. Setting step
to 0
will make the list infinite.
The list of numbers in the range.
import { range, toArray } from "./list.ts";
import { assertEquals } from "../deps.ts";
assertEquals(toArray(range(0, 5)), [0, 1, 2, 3, 4]);
assertEquals(toArray(range(0, 5, 0.5)), [
0,
0.5,
1,
1.5,
2,
2.5,
3,
3.5,
4,
4.5,
]);
assertEquals(toArray(range(2, 3)), [2]);
assertEquals(toArray(range(3, 6)), [3, 4, 5]);
assertEquals(toArray(range(3, 3)), []);
assertEquals(toArray(range(5, 0)), []);
assertEquals(toArray(range(3, 2)), []);
Generated using TypeDoc
Creates the list of numbers from
start
toend
with stepping, adding bystep
.