Mwnci zip() Function

Syntax

zip(array, array, …)

Description

The zip() function pairs multiple arrays into a single array of arrays. Each new array contains elements from the input arrays that are in the same position.

If the passed arrays have different lengths, the array with the least items decides the length of the new iterator.

Example

Names=["Bob", "Jim", "Fred", "Ted"]
Ages=[40,45,68,61,92]
Pets=["Parrot", "Goat", "Cat"]
a=zip(Names, Ages, Pets)
println(a)


[["Bob", 40, "Parrot"], ["Jim", 45, "Goat"], ["Fred", 68, "Cat"]]