Might there be a standard lib function that let's ...
# announcements
d
Might there be a standard lib function that let's me mix two lists?
listOf("a", "b", "c") + listOf("d", "e") = listOf("a", "d", "b", "e", c")
e
Aye, use this: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/union.html However, it returns
Set
, so you may lose similar elements
d
Hmhm, I get abcde with this, seems there is no mixing. But thank you for your reply anyway!
n
fun <T> merge(a: List<T>, b: List<T>): List<T> { var merged =  a.zip(b).flatMap { it.toList() }; return merged + a.drop(merged.size / 2) + b.drop(merged.size / 2) }