runningReduce<S> method
Returns a list containing successive accumulation values generated by applying operation
from left to right to each element and current accumulator value that starts with the first element of this collection.
Implementation
@useResult
KtList<S> runningReduce<S>(S Function(S acc, T) operation) {
final i = iterator();
if (!i.hasNext()) {
return emptyList();
}
S accumulator = i.next() as S;
final result = mutableListOf<S>()..add(accumulator);
while (i.hasNext()) {
accumulator = operation(accumulator, i.next());
result.add(accumulator);
}
return result;
}