Array node

Array Zip

Merge two arrays element-wise into an array of pairs. Each output element is a two-element sub-array [A[i], B[i]]. Choose how to handle arrays of different lengths.

Inputs

PortTypeDefault
Array AThe first list — its elements become the left half of each pair.any—
Array BThe second list — its elements become the right half of each pair.any—
ModeWhat to do when the lists differ in length: Shortest stops at the smaller one, Longest runs to the larger and pads the missing side with 0. Values outside the list fall back to Shortest.int0

Outputs

PortType
Resultany
Countint

How It Works

Array Zip pairs elements from Array A and Array B by position. Each output element is a sub-array containing [A[i], B[i]].

Mode controls behavior when arrays have different lengths:

  • 0 — Shortest: Stop at the shorter array's length. Excess elements from the longer array are discarded.
  • 1 — Longest: Continue to the longer array's length. Missing elements from the shorter array are filled with 0.

Use Cases

  • XY coordinate pairs: Zip an array of X values with an array of Y values to create coordinate pairs for plotting.
  • Label-value association: Zip a labels array with a values array to create labeled data points.
  • Multi-channel correlation: Pair corresponding samples from two EEG channels for coherence analysis.

Tips

  • To split a zipped array back into two arrays, use Array Map or access sub-elements with Array Get.
  • For simple alternating merge (A₀, B₀, A₁, B₁...) instead of pairs ([A₀,B₀], [A₁,B₁]...), use Array Join with Interleave mode.

Open Array Zip in the interactive catalog →

Array Zip is one of 381 nodes in Grafit Pro.

Free download. Every feature for 7 days, no card. Then €99.99 once — or keep playing your projects as a Player.

More Array nodes