arrow-fx-coroutines / arrow.fx.coroutines.stream / interleaveAll

interleaveAll

fun <O> Stream<O>.interleaveAll(that: Stream<O>): Stream<O>

Deterministically interleaves elements, starting on the left, terminating when the ends of both branches are reached naturally.

import arrow.fx.coroutines.stream.*

//sampleStart
suspend fun main(): Unit =
  Stream(1, 2, 3)
    .interleaveAll(Stream(4, 5, 6, 7))
    .toList()
    .let(::println) //[1, 4, 2, 5, 3, 6, 7]
//sampleEnd

Do you like Arrow?

Arrow Org
<