Tsallaka zuwa abun ciki
Justice Tech School

zip, flatten and windowed

zip pairs two lists, flatten merges nested lists and windowed makes sliding windows.

Example
println(listOf(1, 2).zip(listOf("a", "b")))
println(listOf(listOf(1), listOf(2, 3)).flatten())
println(listOf(1, 2, 3, 4).windowed(2))
println(listOf(1, 2, 3, 4).chunked(2))

Exercise

Pair lists.

a.(b)

Quiz Test

What does chunked(2) do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.