• Creates a list such that whenever v_i has finite index in list i for each i, [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.

    Type Parameters

    • T

    Parameters

    • listList: List<List<T>>

      The finite list of (possibly infinite) list.

    Returns List<List<T>>

    The choose list.

    Examples

    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