align
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 =
listOf("A", "B").align(listOf(1, 2, 3)) {
"$it"
}
//sampleEnd
println(result)
}
Content copied to clipboard
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 =
listOf("A", "B").align(listOf(1, 2, 3))
//sampleEnd
println(result)
}
Content copied to clipboard
Combines two structures by taking the union of their shapes and combining the elements with the given function.
import arrow.core.align
fun main(args: Array<String>) {
//sampleStart
val result =
sequenceOf("A", "B").align(sequenceOf(1, 2, 3)) {
"$it"
}
//sampleEnd
println(result.toList())
}
Content copied to clipboard
Combines two structures by taking the union of their shapes and using Ior to hold the elements.
import arrow.core.align
fun main(args: Array<String>) {
//sampleStart
val result =
sequenceOf("A", "B").align(sequenceOf(1, 2, 3))
//sampleEnd
println(result.toList())
}
Content copied to clipboard
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)
}
Content copied to clipboard
fun <K, A, B, C> Map<K, A>.align(b: Map<K, B>, fa: (Map.Entry<K, Ior<A, B>>) -> C): Map<K, C>(source)
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)
}
Content copied to clipboard