The zip function combines two lists into tuples. If the lists are of differing lengths, the shorter length is used. If you don’t like this behavior, the zipAll function will keep all elements, filling in specified values for the blanks (compare this to the recycling rule in R, which lets you continuously cycle through the shorter list).
val a = List("a", "b", "c", "d")
val b = List(1, 2, 3);
println(a.zipAll(b, "for missing values", 100))
And here is the output for each:
List((a,1), (b,2), (c,3)) List((a,1), (b,2), (c,3), (d,100))
Thanks, The example is very concise and clear.