padZip
Returns a List> containing the zipped values of the two lists with null for padding.
Example:
import arrow.core.*
//sampleStart
val padRight = listOf(1, 2).padZip(listOf("a")) // Result: [Pair(1, "a"), Pair(2, null)]
val padLeft = listOf(1).padZip(listOf("a", "b")) // Result: [Pair(1, "a"), Pair(null, "b")]
val noPadding = listOf(1, 2).padZip(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 List containing the result of applying some transformation (A?, B?) -> C
on a zip.
Example:
import arrow.core.*
//sampleStart
val padZipRight = listOf(1, 2).padZip(listOf("a")) { l, r -> l to r } // Result: [Pair(1, "a"), Pair(2, null)]
val padZipLeft = listOf(1).padZip(listOf("a", "b")) { l, r -> l to r } // Result: [Pair(1, "a"), Pair(null, "b")]
val noPadding = listOf(1, 2).padZip(listOf("a", "b")) { l, r -> l to r } // Result: [Pair(1, "a"), Pair(2, "b")]
//sampleEnd
fun main() {
println("padZipRight = $padZipRight")
println("padZipLeft = $padZipLeft")
println("noPadding = $noPadding")
}
Content copied to clipboard
Returns a Sequence> containing the zipped values of the two sequences with null for padding.
Example:
import arrow.core.padZip
//sampleStart
val padRight = sequenceOf(1, 2).padZip(sequenceOf("a")) // Result: [Pair(1, "a"), Pair(2, null)]
val padLeft = sequenceOf(1).padZip(sequenceOf("a", "b")) // Result: [Pair(1, "a"), Pair(null, "b")]
val noPadding = sequenceOf(1, 2).padZip(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
Returns a Sequence containing the result of applying some transformation (A?, B?) -> C
on a zip.
Example:
import arrow.core.padZip
//sampleStart
val padZipRight = sequenceOf(1, 2).padZip(sequenceOf(3)) { l, r -> (l?:0) + (r?:0) } // Result: [4, 2]
val padZipLeft = sequenceOf(1).padZip(sequenceOf(3, 4)) { l, r -> (l?:0) + (r?:0) } // Result: [4, 4]
val noPadding = sequenceOf(1, 2).padZip(sequenceOf(3, 4)) { l, r -> (l?:0) + (r?:0) } // Result: [4, 6]
//sampleEnd
fun main() {
println("padZipRight = $padZipRight")
println("padZipLeft = $padZipLeft")
println("noPadding = $noPadding")
}
Content copied to clipboard
Align two structures as in zip, but filling in blanks with null.