reduce


Description:

public U reduce<U> (U initial, owned ReduceFunc<T,U> fn)

Folds the stream into a single value by applying the accumulator function to each element, starting from the initial value.

Example:

    int sum = stream.reduce<int> (0, (acc, x) => { return acc + x; });

Parameters:

initial

the initial accumulator value.

fn

the accumulator function.

Returns:

the accumulated result.