Reputation: 234
I'm looking for a "chunkBy" kind of operator that provides the below functionality:
test("chunkBy") {
val s = Stream(1, 2, 3, 4, 5, 6, 7, 8).covary[IO]
val range = 4
val actual: List[(Int, Chunk[Int])] = s.chunkBy(element => element % range).toList
val expected = List((1, Chunk(1,5)), (2, Chunk(2,6)), (3, Chunk(3,7)), (4, Chunk(4,8)))
assertEquals(actual, expected)
}
note: chunkBy
is the operator I'm looking for.
I couldn't find any such API provided by FS2 to create chunks out of a stream based on predicates.
Upvotes: 0
Views: 352