interleave

fun <A> Iterable<A>.interleave(other: Iterable<A>): List<A>(source)

interleave both computations in a fair way.

import arrow.core.*

fun main(args: Array<String>) {
//sampleStart
val tags = List(10) { "#" }
val result =
tags.interleave(listOf("A", "B", "C"))
//sampleEnd
println(result)
}

interleave both computations in a fair way.

import arrow.core.interleave

fun main(args: Array<String>) {
//sampleStart
val tags = generateSequence { "#" }.take(10)
val result =
tags.interleave(sequenceOf("A", "B", "C"))
//sampleEnd
println(result.toList())
}