arrow-core-data / arrow.core / kotlin.collections.Map / align
fun <K, A, B>
Map
<K, A>.align(b:
Map
<K, B>):
Map
<K,
Ior
<A, B>>
Combines two structures by taking the union of their shapes and using Ior to hold the elements.
import arrow.core.*
fun main(args: Array<String>) {
//sampleStart
val result =
mapOf("1" to 1, "2" to 2).align(mapOf("1" to 1, "2" to 2, "3" to 3))
//sampleEnd
println(result)
}
fun <K, A, B, C>
Map
<K, A>.align(b:
Map
<K, B>, fa: (
Entry
<K,
Ior
<A, B>>) -> C):
Map
<K, C>
Combines two structures by taking the union of their shapes and combining the elements with the given function.
import arrow.core.*
fun main(args: Array<String>) {
//sampleStart
val result =
mapOf("1" to 1, "2" to 2).align(mapOf("1" to 1, "2" to 2, "3" to 3)) { (_, a) ->
"$a"
}
//sampleEnd
println(result)
}
Do you like Arrow?
✖