#zip
Combines two arrays pairwise using a two-parameter lambda.
#zip(first, second, @x;@y: combine)Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
first |
path | array |
The first array. |
second |
path | array |
The second array. |
combine |
lambda |
Receives one element from each array and returns the combined value. |
Returns
Section titled “Returns”array
Examples
Section titled “Examples”Pair numbers with letters
Section titled “Pair numbers with letters”{ "numbers": [ 1, 2 ], "letters": [ "a", "b" ]}{ "result": "#zip($.numbers, $.letters, @x;@y: { 'first': @x, 'second': @y })"}{ "result": [ { "first": 1, "second": "a" }, { "first": 2, "second": "b" } ]}