arrow-fx-coroutines / arrow.fx.coroutines.stream / scanChunks
fun <O, S, O2> Pull<O, Unit>.scanChunks(init: S, f: (S, Chunk<O>) -> Pair<S, Chunk<O2>>): Pull<O2, S>
Like scan but f is applied to each chunk of the source stream.
The resulting chunk is emitted and the result of the chunk is used in the
next invocation of f. The final state value is returned as the result of the pull.
fun <O, S, O2> Stream<O>.scanChunks(init: S, f: (S, Chunk<O>) -> Pair<S, Chunk<O2>>): Stream<O2>
Like scan but f is applied to each chunk of the source stream.
The resulting chunk is emitted and the result of the chunk is used in the
next invocation of f.
Many stateful pipes can be implemented efficiently (i.e., supporting fusion) with this method.
Do you like Arrow?
✖