arrow-core-data / arrow.core / kotlin.sequences.Sequence / unzip
fun <A, B>
Sequence
<
Pair
<A, B>>.unzip():
Pair
<
Sequence
<A>,
Sequence
<B>>
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()})")
}
fun <A, B, C>
Sequence
<C>.unzip(fc: (C) ->
Pair
<A, B>):
Pair
<
Sequence
<A>,
Sequence
<B>>
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()})")
}
Do you like Arrow?
✖