OxL Reference

method List.fold

Folds the list from the left: f(acc, x) for every element, starting from start.

Example:

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

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/collections.oxl:477

See also