🧩 Accumulates values using a reducer function.
Syntax
TypeScript
import { reduceIter } from '@opentf/std'; reduceIter<T, U>(iter: Iterable<T>, fn: (acc: U, val: T) => U, initialValue: U): U
Parameters
iter: The source iterable.fn: The reducer function.initialValue: The initial value for the accumulator.
Returns
The final accumulator value.
Examples
TypeScript
reduceIter([1, 2, 3], (acc, x) => acc + x, 0) //=> 6