Function itertools::fold[][src]

pub fn fold<I, B, F>(iterable: I, init: B, f: F) -> B where
    I: IntoIterator,
    F: FnMut(B, I::Item) -> B, 
Expand description

Perform a fold operation over the iterable.

IntoIterator enabled version of Iterator::fold.

use itertools::fold;

assert_eq!(fold(&[1., 2., 3.], 0., |a, &b| f32::max(a, b)), 3.);