This function emulates Python's zip function. It expects a variable number of arguments. If a single vector/list x is passed the return value is a list of lists where each sub-list contains the components “key” and “value”. If x is named the key is the name, otherwise it is the element number. The value field unsuprisingly contains the corresponding value.
zip(...)
... | [Lists/vectors] |
---|
A list of lists.
x = list("a" = 1, "b" = 2, "c" = 3) for (el in zip(x)) { catf("Key: '%s', Value: %i\n", el$key, el$value) }#> Key: 'a', Value: 1 #> Key: 'b', Value: 2 #> Key: 'c', Value: 3z = zip(x, x)