it's possible via scan (use Pair<Int, Int> as an accumulator), but easier to write your own zipWithNext function, it's pretty simple
d
Dragos Rachieru
10/03/2022, 4:26 PM
Thank you
l
Lukas Lechner
10/04/2022, 5:59 PM
What about .reduce() or fold()? With those you also have access to the previous and the current value.
e
ephemient
10/04/2022, 6:02 PM
fold is similar to scan, so you need to provide an initial value. reduce throws if the flow was empty. those might work for Dragos, depends on the situation though
d
Dragos Rachieru
10/04/2022, 7:23 PM
I want to emit these values further, i think I can put them in a list of lists and then send them further