arrow-fx-coroutines / arrow.fx.coroutines.stream / zipAllWith
fun <A, B, C>
Stream
<A>.zipAllWith(that:
Stream
<B>, pad1: A, pad2: B, f: (A, B) -> C):
Stream
<C>
Deterministically zips elements with the specified function, terminating
when the ends of both branches are reached naturally, padding the left
branch with pad1
and padding the right branch with pad2
as necessary.
import arrow.fx.coroutines.stream.*
//sampleStart
suspend fun main(): Unit =
Stream(1,2,3)
.zipAllWith(Stream(4,5,6,7), 0, 0) { acc, b -> acc + b }
.toList().let(::println) // [5, 7, 9, 7]
//sampleEnd
Do you like Arrow?
✖