accumulate method
- T init, [
- T op(
- T,
- T
Sums up or folds the elements in the range, starting with init.
Similar to std::accumulate. The default operation is addition,
but a custom op can be provided. Note that if no custom op is provided,
T must support the + operator.
Implementation
T accumulate(T init, [T Function(T, T)? op]) {
op ??= (T a, T b) => ((a as dynamic) + (b as dynamic)) as T;
return fold(init, op);
}