@mikuroxina/mini-fn
    Preparing search index...

    Function spanNot

    • 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: T) => boolean

        The condition to split.

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

      The tuple of split of the list.

      Examples

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