runningReduce
Returns a sequence 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 sequence.
fun <S, T : S> Sequence<T>.runningReduce(operation: (acc: S, T) -> S): Sequence<S>(source)
val numbers = sequenceOf(1, 2, 3, 4)
val runningSums = numbers.runningReduce { acc, n -> acc + n }
println(runningSums.toList()) // Output: [1, 3, 6, 10]