reduce
reduce<
T,U>(func: (acc:U,val:T) =>U,iterable:Iterable<T>,initializer?:U):U
Defined in: packages/pythonlib/src/functools.ts:34
Apply a function of two arguments cumulatively to the items of an iterable reduce((x, y) => x + y, [1, 2, 3, 4, 5]) returns 15 reduce((x, y) => x + y, [1, 2, 3, 4, 5], 10) returns 25
Type Parameters
| Type Parameter | Default type |
|---|---|
T | - |
U | T |
Parameters
| Parameter | Type |
|---|---|
func | (acc: U, val: T) => U |
iterable | Iterable<T> |
initializer? | U |
Returns
U