method iter.fold
Combines the elements with f, starting from start: f(f(start, x1), x2) ...
Example:
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 FComplexity. O(n).
Since. 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/iter.oxl:650