The choose list.
import { fromArray, fromString, choices, range, toArray } from "./list.ts";
import { assertEquals } from "../deps.ts";
const choice = choices(fromArray([range(0, 3), range(3, 6)]));
const sequences = toArray(choice).map((seq) => toArray(seq));
assertEquals(sequences, [
[0, 3],
[0, 4],
[1, 3],
[0, 5],
[1, 4],
[2, 3],
[1, 5],
[2, 4],
[2, 5],
]);
Generated using TypeDoc
Creates a list such that whenever
v_i
has finite index in listi
for eachi
,[v_1, v_2, ..., v_n]
has finite index in the output list. It is different to cartesian product, so the order of elements are not sorted.