reduce


Description:

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

Reduces the list to a single value by applying the given function to each element, accumulating the result from the initial value.

Example:

    var list = new ArrayList<string> (GLib.str_equal);
list.add ("a");
list.add ("b");
list.add ("c");
var joined = list.reduce<string> ("", (acc, s) => {
return acc + s;
});
assert (joined == "abc");

Parameters:

initial

the initial accumulator value.

func

the reduction function.

Returns:

the final accumulated value.