Skip to main content

Iterator: Reduce

Fold a list into a single value. The sub-graph runs once per element with el, index, and the running accumulator acc exposed by the auto-created Iterator::Entry. Each iteration's new accumulator is read from the auto-created Iterator::Collect.

Mirrors JavaScript's Array.prototype.reduce.

Example
Input array: [1, 2, 3, 4]
Initial value: 0
Body: acc + el
Output: 10

Parameters

This function has no parameters.

Input

ArrayREQUIRED

List to fold over (Array or JSON array).

InitialREQUIRED
Starting value for the accumulator.

Output

Result

The final accumulator value after all iterations.