• Creates subsequences of the list.

    Type Parameters

    • T

    Parameters

    • list: List<T>

      The source list.

    Returns List<List<T>>

    The list having subsequences.

    Examples

    import { fromArray, subsequences, toArray } from "./list.ts";
    import { assertEquals } from "../deps.ts";

    const subSeq = subsequences(fromArray([1, 2, 3, 4]));
    const sequences = toArray(subSeq).map((seq) => toArray(seq));
    assertEquals(sequences, [
    [],
    [1],
    [2],
    [1, 2],
    [3],
    [1, 3],
    [2, 3],
    [1, 2, 3],
    [4],
    [1, 4],
    [2, 4],
    [1, 2, 4],
    [3, 4],
    [1, 3, 4],
    [2, 3, 4],
    [1, 2, 3, 4],
    ]);

Generated using TypeDoc