arrow-fx-coroutines / arrow.fx.coroutines.stream / zipAll

zipAll

fun <O, B> Stream<O>.zipAll(that: Stream<B>, pad1: O, pad2: B): Stream<Pair<O, B>>

Deterministically zips elements, 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)
    .zipAll(Stream(4,5,6,7), 0,0)
    .toList().let(::println) // [(1,4), (2,5), (3,6), (0,7)]
//sampleEnd

Do you like Arrow?

Arrow Org
<