ts-iterable-functions
    Preparing search index...

    Function _reduceRight

    • Aggregates a sequence from right to left by iteratively combining elements.

      Type Parameters

      • T

        Element type produced by the source iterable.

      • TOut

        Accumulator result type when a distinct seed is supplied.

      Parameters

      • src: Iterable<T>

        Source iterable to be reduced.

      • aggFunc: (prev: TOut, curr: T, idx: number) => TOut

        Combiner invoked with the previous accumulator, current element, and current index counted from the right.

      • seed: TOut

        Optional initial accumulator; falls back to the rightmost element when omitted.

      Returns TOut

      The final accumulator after iterating from the last element to the first.

      If seed is omitted and the source iterable is empty.

      const diff = _reduceRight([1, 2, 3], (prev, curr) => prev - curr);
      console.log(diff); // 0 => ((3 - 2) - 1)

      const total = _reduceRight([1, 2, 3], (prev, curr) => prev + curr, 0);
      console.log(total); // 6
    • Aggregates a sequence from right to left by iteratively combining elements.

      Type Parameters

      • T

        Element type produced by the source iterable.

      Parameters

      • src: Iterable<T>

        Source iterable to be reduced.

      • aggFunc: (prev: T, curr: T, idx: number) => T

        Combiner invoked with the previous accumulator, current element, and current index counted from the right.

      Returns T

      The final accumulator after iterating from the last element to the first.

      If seed is omitted and the source iterable is empty.

      const diff = _reduceRight([1, 2, 3], (prev, curr) => prev - curr);
      console.log(diff); // 0 => ((3 - 2) - 1)

      const total = _reduceRight([1, 2, 3], (prev, curr) => prev + curr, 0);
      console.log(total); // 6