Skip to content

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 ParameterDefault type
T-
UT

Parameters

ParameterType
func(acc: U, val: T) => U
iterableIterable<T>
initializer?U

Returns

U