Description
Combines two lists element-by-element into a list of pairs. Each pair contains one element from the first list and the corresponding element from the second list. The resulting list has the length of the shorter input list.Syntax
Parameters
Returns
Type: list of lists A list where each element is a two-element array[item1, item2] combining corresponding elements from both lists. Returns an empty list if either input is not an array.
Examples
Example 1: Basic Zipping
Example 2: Different Length Lists
Example 3: Creating Key-Value Pairs
Example 4: Pairing Related Data
Notes
- Returns empty list if either input is not an array or is
null - Result length is limited by the shorter of the two input lists
- Excess elements from the longer list are ignored
- Useful for pairing related data or creating key-value associations
See Also
- map.fromPairs - Convert pairs to a map
- coll.union - Combine lists as sets
Frequently Asked Questions
What does flex.coll.zip return?
What does flex.coll.zip return?
It returns a list of two-element lists (pairs), combining elements from two input lists by position. For example,
flex.coll.zip([1,2], ['a','b']) returns [[1,'a'],[2,'b']].What happens if the input lists have different lengths?
What happens if the input lists have different lengths?
The result length matches the shorter list. Extra elements from the longer list are ignored.