Skip to main content

reduceRight()

reduceRight<T, R>(fn): (initVal) => (arr) => R

Calls the accumulator with each element of the given array, starting with the last element. Returns the final result.

Type Parameters

T

The type of array elements.

R

The result type of the folder function.

Parameters

fn

Accumulator<T, R>

The accumulator function to apply to each element of the array.

Returns

Function

Parameters

initVal

R

Returns

Function

Parameters

arr

T[]

Returns

R

Remarks

pure function

Example

import { reduceRight } from '@accelint/core';

reduceRight((base, s) => `${base}${s}`)('')(['a', 'b', 'c', 'd', 'e']);
// 'edcba'