reduceIndexedOrNull<S> method
Accumulates value starting with the first element and applying operation
from left to right
to current accumulator value and each element with its index in the original collection.
Returns null if the list is empty.
Implementation
S? reduceIndexedOrNull<S>(S Function(int index, S acc, T) operation) {
final i = iterator();
if (!i.hasNext()) {
return null;
}
var index = 1;
S accumulator = i.next() as S;
while (i.hasNext()) {
accumulator = operation(index++, accumulator, i.next());
}
return accumulator;
}