Is it possible to transform a flow into a flow tha...
# coroutines
j
Is it possible to transform a flow into a flow that emits a rolling window of N elements? As if:
Copy code
flowOf<Int>(0,1,2,3,4,5,6,7,8,9).magicOperator(2).collect { values: List<Int> ->
 print("${values}; ")
}
Would print:
0,1; 1,2; 2,3; 3,4; 4,5; 5,6; 6,7; 7,8; 8,9
e
j
I don't think
chunked
is relevant here, it's more about
windowed
or
zipWithNext
m
you can try to hack a way with scan operator maybe ?
j
The proposed implementation of
zipWithNext
did it great! Thanks!
e
@Joffrey chunked isn't relevant but comments and PRs there include both chunked and windowed
👌 1