//arrow-core/arrow.core/interleave

interleave

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

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)
}

common fun <A> Sequence<A>.interleave(other: Sequence<A>): Sequence<A>

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())
}

Do you like Arrow?

Arrow Org
<