libminizinc icon indicating copy to clipboard operation
libminizinc copied to clipboard

Feature request: Add zip function for array1d

Open jaanonim opened this issue 2 months ago • 0 comments

Add a zip function for the array1d class to allow easy combination of two arrays into an one array, similar to Python’s built-in zip(). I think it could be handy to have it buildin.

Here is my mockup of how it could be written:

function array[int] of var $T: zip(array [$$I] of var $T: x, array [$$I] of var $T: y) = array1d(
  min(index_set(x))..min(index_set(x))+length(x)*2-1,
  [ 
    if i mod 2 = 1 then array1d(x)[(i+1) div 2] 
    else array1d(y)[i div 2] endif 
    | i in 1..length(x)*2
  ]
);

jaanonim avatar Nov 05 '25 21:11 jaanonim