interleave

fun <T> interleave(iterables: Iterable<Iterable<T>>): Sequence<T>

Lazily interleaves the elements of the given iterables, round-robin style: the first element of every iterable, then the second element of every (still non-exhausted) iterable, and so on, until all of them are exhausted. Unlike merge, this does not require the inputs to be sorted, and does not reorder elements based on their value, only on their position within their originating iterable.


fun <T> interleave(vararg iterables: Iterable<T>): Sequence<T>

Same as interleave, taking the iterables to interleave as varargs.


fun <T> interleave(iterables: Sequence<Iterable<T>>): Sequence<T>

Same as interleave, taking the outer collection of iterables as a Sequence.