reduce

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

Accumulates value starting with the first element and applying operation to current accumulator value and each element. Throws UnsupportedOperationException if flow was empty.