reduceValue<T> method
Reduces values of elements in a collection to a single value by iteratively combining its using the provided function.
The iterable must have at least one element. If it has only one element, that element is returned.
Implementation
T reduceValue<T>(
T Function(T value, T elementVal) combine, GetValue<E, T> getVal) {
final iterator = this.iterator;
if (!iterator.moveNext()) {
throw StateError('No element');
}
var value = getVal(iterator.current);
while (iterator.moveNext()) {
value = combine(value, getVal(iterator.current));
}
return value;
}