• Finds the positions of element which satisfies pred in the list. If the list is infinite, this will hang forever.

    Type Parameters

    • T

    Parameters

    • pred: ((value) => boolean)

      The match condition of element to find.

        • (value): boolean
        • Parameters

          • value: T

          Returns boolean

    Returns ((list) => number[])

    The found positions.

    Examples

    import { findIndices, fromArray } from "./list.ts";
    import * as Option from "./option.ts";
    import { assertEquals } from "../deps.ts";

    const list = fromArray([1, 4, 2, 3, 5]);

    assertEquals(findIndices((x: number) => 4 <= x)(list), [1, 4]);
    assertEquals(findIndices((x: number) => 0 <= x)(list), [0, 1, 2, 3, 4]);
    assertEquals(findIndices((x: number) => 8 <= x)(list), []);
      • (list): number[]
      • Parameters

        Returns number[]

Generated using TypeDoc