arrow-core-data / arrow.core / kotlin.collections.Iterable / padZip
fun <A, B>
Iterable
<A>.padZip(other:
Iterable
<B>):
List
<
Pair
<A?, B?>>
Returns a ListPairA?,B? 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")
}
inline fun <A, B, C>
Iterable
<A>.padZip(other:
Iterable
<B>, fa: (A?, B?) -> C):
List
<C>
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")
}
Do you like Arrow?
✖