xxfast
12/13/2022, 11:15 PMzipWithNull
(as seen on #advent-of-code)
fun <T, R> Iterable<T>.zipWithNull(other: Iterable<R>): List<Pair<T?, R?>> = buildList {
val first = this@zipWithNull.iterator()
val second = other.iterator()
while (first.hasNext() || second.hasNext()) {
val left = if (first.hasNext()) first.next() else null
val right = if (second.hasNext()) second.next() else null
add(left to right)
}
}
simon.vergauwen
12/14/2022, 7:39 AMzipAll
as know from some other languages.
https://youtrack.jetbrains.com/issue/KT-13017