Does Kotlin have something similar to RxJava scan?


#1

I have a simple list (or sequence) of Pair(charSequence, Int)

(C0, 0), (C1, 1), (C2, 2), (C3, 3), …

I would like to accumulate the ints and produce
(C0, 0), (C1, 1), (C2, 3), (C3, 6)

It’s quite easy to do in imperative style, but what about fonctionnal style :
Is there a way to do that with an operator on lists/sequences in Kotlin ? with Java8 and streams ?

It is possible to do in RxJava with the operator scan
http://reactivex.io/documentation/operators/scan.html

Also, I often wonder if the Kotlin operators on iterable/sequences in the std lib are not a bit lacking compared to RxJava operators/transformers.
The RxJava api seems a lot more full featured while not being bloated


Reductions / cumulative sum
#2

I second the need for this. Basically scan is like fold except that instead of giving you just the last value it gives you the seed and all intermediate values