arrow-core-data / arrow.core / kotlin.collections.Iterable / unzip
fun <A, B>
Iterable
<
Pair
<A, B>>.unzip():
Pair
<
List
<A>,
List
<B>>
unzips the structure holding the resulting elements in an Pair
import arrow.core.*
fun main(args: Array<String>) {
//sampleStart
val result =
listOf("A" to 1, "B" to 2).k().unzip()
//sampleEnd
println(result)
}
inline fun <A, B, C>
Iterable
<C>.unzip(fc: (C) ->
Pair
<A, B>):
Pair
<
List
<A>,
List
<B>>
after applying the given function unzip the resulting structure into its elements.
import arrow.core.*
fun main(args: Array<String>) {
//sampleStart
val result =
listOf("A:1", "B:2", "C:3").k().unzip { e ->
e.split(":").let {
it.first() to it.last()
}
}
//sampleEnd
println(result)
}
Do you like Arrow?
✖