fold

inline fun <T, R> Sequence<T>.fold(initial: R, operation: (R, T) -> R): R(source)

Accumulates elements in order, passing the accumulator before the current element. Returns initial for an empty sequence without invoking operation. Exceptions propagate; the immediate inline callback admits non-local returns.