unzip
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).unzip()
//sampleEnd
println(result)
}
Content copied to clipboard
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").unzip { e ->
e.split(":").let {
it.first() to it.last()
}
}
//sampleEnd
println(result)
}
Content copied to clipboard
unzips the structure holding the resulting elements in an Pair
import arrow.core.unzip
fun main(args: Array<String>) {
//sampleStart
val result = sequenceOf("A" to 1, "B" to 2).unzip()
//sampleEnd
println("(${result.first.toList()}, ${result.second.toList()})")
}
Content copied to clipboard
after applying the given function unzip the resulting structure into its elements.
import arrow.core.unzip
fun main(args: Array<String>) {
//sampleStart
val result =
sequenceOf("A:1", "B:2", "C:3").unzip { e ->
e.split(":").let {
it.first() to it.last()
}
}
//sampleEnd
println("(${result.first.toList()}, ${result.second.toList()})")
}
Content copied to clipboard
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)
}
Content copied to clipboard
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)
}
Content copied to clipboard