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