• Splits the list into a tuple of the longest prefix does NOT satisfy pred and the rest. It is equivalent to span((item) => !pred(item)).

    Type Parameters

    • T

    Parameters

    • pred: ((t) => boolean)

      The condition to split.

        • (t): boolean
        • Parameters

          • t: T

          Returns boolean

    Returns ((list) => [List<T>, List<T>])

    The tuple of split of the list.

    Examples

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

    {
    const [left, right] = spanNot((x: number) => x > 3)(
    fromArray([1, 2, 3, 4, 1, 2, 3, 4]),
    );
    assertEquals(toArray(left), [1, 2, 3]);
    assertEquals(toArray(right), [4, 1, 2, 3, 4]);
    }
    {
    const [left, right] = spanNot((x: number) => x < 9)(
    fromArray([1, 2, 3]),
    );
    assertEquals(toArray(left), []);
    assertEquals(toArray(right), [1, 2, 3]);
    }
    {
    const [left, right] = spanNot((x: number) => x > 9)(
    fromArray([1, 2, 3]),
    );
    assertEquals(toArray(left), [1, 2, 3]);
    assertEquals(toArray(right), []);
    }

Generated using TypeDoc