cppReduce method
- T op(
- T,
- T
Computes a result using an operation over the elements.
Similar to std::reduce. The difference in C++ is that std::reduce can be executed out of order,
but here it operates sequentially unless parallelized. It differs from Dart's reduce only
by defaulting the op to addition if not provided.
Throws a StateError if the iterable is empty.
Implementation
T cppReduce([T Function(T, T)? op]) {
op ??= (T a, T b) => ((a as dynamic) + (b as dynamic)) as T;
return reduce(op);
}