reduceIndexed method
Accumulates value starting with the first element and applying combine
function from left to right to current accumulator value and each element
with its index in the original collection.
Implementation
E reduceIndexed(E Function(int index, E value, E element) combine) {
if (isEmpty) throw NoSuchElementException();
final iterator = this.iterator..moveNext();
int index = 1;
E value = iterator.current;
while (iterator.moveNext()) {
value = combine(index++, value, iterator.current);
}
return value;
}