I have
[1,2,3,2,4,5,0,2,1,3,4,5,2,2,1,4,5]
What I want as output is
[[1,2,3,2,4,5],[1,3,4,5],[1,4,5]]
This means I want to extract blocks from the input sequence with some start marker, here 1, and some end marker, here 5.
Elements in between these blocks are ignored.
Is there a readable combination of rx-java operators for achieving this?
Yes. You need the
bufferoperator that takes an opening and closing idicator. Since the elements themselves are the indicators, you'll have topublishthe original sequence and funnel them into the indicators too.