scanReduce

@ExperimentalCoroutinesApi fun <T> Flow<T>.scanReduce(
    operation: suspend (accumulator: T, value: T) -> T
): Flow<T>
(source)

Reduces the given flow with operation, emitting every intermediate result, including initial value. The first element is taken as initial value for operation accumulator. This operator has a sibling with initial value – scan.

For example:

flowOf(1, 2, 3, 4).scanReduce { (v1, v2) -> v1 + v2 }.toList()

will produce [1, 3, 6, 10]