arrow-core-data / arrow.core / ListK / rightPadZip
fun <B, C> rightPadZip(other:
ListK
<B>, fa: (A, B?) -> C):
ListK
<C>
Returns a ListK containing the result of applying some transformation (A, B?) -> C
on a zip, excluding all cases where the left value is null.
Example:
import arrow.core.*
//sampleStart
val left = listOf(1, 2).k().rightPadZip(listOf("a").k()) { l, r -> l toT r }.k() // Result: ListK(Tuple2(1, "a"), Tuple2(null, "b"))
val right = listOf(1).k().rightPadZip(listOf("a", "b").k()) { l, r -> l toT r }.k() // Result: ListK(Tuple2(1, "a"))
val both = listOf(1, 2).k().rightPadZip(listOf("a", "b").k()) { l, r -> l toT r }.k() // Result: ListK(Tuple2(1, "a"), Tuple2(2, "b"))
//sampleEnd
fun main() {
println("left = $left")
println("right = $right")
println("both = $both")
}
fun <B> rightPadZip(other:
ListK
<B>):
ListK
<
Tuple2
<A, B?>>
Returns a ListKTuple2A,B? containing the zipped values of the two listKs with null for padding on the right.
Example:
import arrow.core.*
//sampleStart
val padRight = listOf(1, 2).k().rightPadZip(listOf("a").k()) // Result: ListK(Tuple2(1, "a"), Tuple2(2, null))
val padLeft = listOf(1).k().rightPadZip(listOf("a", "b").k()) // Result: ListK(Tuple2(1, "a"))
val noPadding = listOf(1, 2).k().rightPadZip(listOf("a", "b").k()) // Result: ListK(Tuple2(1, "a"), Tuple2(2, "b"))
//sampleEnd
fun main() {
println("left = $left")
println("right = $right")
println("both = $both")
}
Do you like Arrow?
✖