Function reduce

  • Remarks

    The initial value is mandatory. This is required so accumulator can accept different types for acc and next.

    Example

    import * as A from "flurp/array";

    const concatWithLabel = A.reduce((acc, next) => acc + next, "reduced: ");

    Type Parameters

    • T

    • U

    Parameters

    • accumulator: ((acc: T, next: U) => T)
        • (acc: T, next: U): T
        • Parameters

          • acc: T
          • next: U

          Returns T

    • initial: T

    Returns ((arr: readonly U[]) => T)

      • (arr: readonly U[]): T
      • Parameters

        • arr: readonly U[]

        Returns T