method List.fold
Folds the list from the left: f(acc, x) for every element, starting from start.
Example:
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 FSince. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
start | A |
f | fn(A, T) -> A F |
Returns
A F
Effects
none declared (pure unless the body says otherwise)
Defined in: std/core/collections.oxl:477