rightPadZip
Returns a List 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).rightPadZip(listOf("a")) { l, r -> l to r } // Result: [Pair(1, "a"), Pair(null, "b")]
val right = listOf(1).rightPadZip(listOf("a", "b")) { l, r -> l to r } // Result: [Pair(1, "a")]
val both = listOf(1, 2).rightPadZip(listOf("a", "b")) { l, r -> l to r } // Result: [Pair(1, "a"), Pair(2, "b")]
//sampleEnd
fun main() {
println("left = $left")
println("right = $right")
println("both = $both")
}
Content copied to clipboard
Returns a List> containing the zipped values of the two lists with null for padding on the right.
Example:
import arrow.core.*
//sampleStart
val padRight = listOf(1, 2).rightPadZip(listOf("a")) // Result: [Pair(1, "a"), Pair(2, null)]
val padLeft = listOf(1).rightPadZip(listOf("a", "b")) // Result: [Pair(1, "a")]
val noPadding = listOf(1, 2).rightPadZip(listOf("a", "b")) // Result: [Pair(1, "a"), Pair(2, "b")]
//sampleEnd
fun main() {
println("padRight = $padRight")
println("padLeft = $padLeft")
println("noPadding = $noPadding")
}
Content copied to clipboard
Returns a Sequence 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.rightPadZip
//sampleStart
val left = sequenceOf(1, 2).rightPadZip(sequenceOf(3)) { l, r -> l + (r?:0) } // Result: [4, 2]
val right = sequenceOf(1).rightPadZip(sequenceOf(3, 4)) { l, r -> l + (r?:0) } // Result: [4]
val both = sequenceOf(1, 2).rightPadZip(sequenceOf(3, 4)) { l, r -> l + (r?:0) } // Result: [4, 6]
//sampleEnd
fun main() {
println("left = $left")
println("right = $right")
println("both = $both")
}
Content copied to clipboard
Returns a Sequence> containing the zipped values of the two sequences with null for padding on the right.
Example:
import arrow.core.rightPadZip
//sampleStart
val padRight = sequenceOf(1, 2).rightPadZip(sequenceOf("a")) // Result: [Pair(1, "a"), Pair(2, null)]
val padLeft = sequenceOf(1).rightPadZip(sequenceOf("a", "b")) // Result: [Pair(1, "a")]
val noPadding = sequenceOf(1, 2).rightPadZip(sequenceOf("a", "b")) // Result: [Pair(1, "a"), Pair(2, "b")]
//sampleEnd
fun main() {
println("padRight = $padRight")
println("padLeft = $padLeft")
println("noPadding = $noPadding")
}
Content copied to clipboard