Skip to content

accumulate

accumulate<T>(iterable: Iterable<T>, func?: (acc: T, val: T) => T, initial?: T): T[]

Defined in: packages/pythonlib/src/itertools.ts:306

Make an iterator that returns accumulated sums or accumulated results accumulate([1, 2, 3, 4, 5]) -> [1, 3, 6, 10, 15] accumulate([1, 2, 3, 4, 5], (x, y) => x * y) -> [1, 2, 6, 24, 120]

Type Parameters

Type Parameter
T

Parameters

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

Returns

T[]