Skip to content

Commit cf6675b

Browse files
committed
feat(foldright1): add foldRight1 function
1 parent 0de8eb2 commit cf6675b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,19 @@ export function foldRightFn<T, U>(
335335
return array => (nativeReduceRight as (...args: any[]) => any).call(array, f, initial);
336336
}
337337

338+
export function foldRight1<T>(
339+
array: ArrayLike<T>,
340+
f: (accumulator: T, element: T, index: number) => T
341+
): T {
342+
return (nativeReduceRight as (...args: any[]) => any).call(array, f);
343+
}
344+
345+
export function foldRight1Fn<T>(
346+
f: (accumulator: T, element: T, index: number) => T
347+
): (array: ArrayLike<T>) => T {
348+
return array => foldRight1(array, f);
349+
}
350+
338351
export function foldMap<T, U>(
339352
array: ArrayLike<T>,
340353
f: (accumulator: U, element: U, index: number) => U,

0 commit comments

Comments
 (0)