OxL Reference

method iter.fold

Combines the elements with f, starting from start: f(f(start, x1), x2) ...

Example:

oxl✓ checked in CI
fn main() io {
  print("{[1, 2, 3].iter().fold(100, (acc, x) => acc - x)}")
}
Output
94
pub(api) move fn fold<A, effect F>(start: A, f: fn(A, T) -> A F) -> A  F

Complexity. O(n).

Since. 1.0.0-beta

Parameters

NameType
startA
ffn(A, T) -> A F

Returns

A F

Effects

none declared (pure unless the body says otherwise)

Defined in: std/core/iter.oxl:650

See also