arrow-core-data / arrow.core / ListK / padZip
fun <B> ~~padZip~~(other: ListK<B>): ListK<Tuple2<Option<A>, Option<B>>>
Deprecated: Deprecated, use padZipWithNull instead
Align two Lists as in zip, but filling in blanks with None.
fun <B, C> padZip(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.
Example:
import arrow.core.*
//sampleStart
val padZipRight = listOf(1, 2).k().padZip(listOf("a").k()) { l, r -> l toT r }.k() // Result: ListK(Tuple2(1, "a"), Tuple2(2, null))
val padZipLeft = listOf(1).k().padZip(listOf("a", "b").k()) { l, r -> l toT r }.k() // Result: ListK(Tuple2(1, "a"), Tuple2(null, "b"))
val noPadding = listOf(1, 2).k().padZip(listOf("a", "b").k()) { l, r -> l toT r }.k() // Result: ListK(Tuple2(1, "a"), Tuple2(2, "b"))
//sampleEnd
fun main() {
println("padZipRight = $padZipRight")
println("padZipLeft = $padZipLeft")
println("noPadding = $noPadding")
}
Do you like Arrow?
✖