These functions implement the basic operations on arrays.

Functions and Predicates
function array [int] of $T: '++'(array [int] of $T: x, array [int] of $T: y)

Usage: x++y

Return the concatenation of arrays x and y

function array [int] of var $T: '++'(array [int] of var $T: x, array [int] of var $T: y)

Usage: x++y

Return the concatenation of arrays x and y

function array [int] of var opt $T: '++'(array [int] of var opt $T: x, array [int] of var opt $T: y)

Usage: x++y

Return the concatenation of arrays x and y

function array [int] of $V: array1d(array [$U] of $V: x)

Return array x coerced to index set 1..length(x)

function array [int] of var $V: array1d(array [$U] of var $V: x)

Return array x coerced to index set 1..length(x)

function array [int] of var opt $V: array1d(array [$U] of var opt $V: x)

Return array x coerced to index set 1..length(x)

function array [int] of $V: array1d(set of int: S, array [$U] of $V: x)

Return array x coerced to one-dimensional array with index set S

function array [int] of var $V: array1d(set of int: S, array [$U] of var $V: x)

Return array x coerced to one-dimensional array with index set S

function array [int] of var opt $V: array1d(set of int: S, array [$U] of var opt $V: x)

Return array x coerced to one-dimensional array with index set S

function array [int,int] of $V: array2d(set of int: S1, set of int: S2, array [$U] of $V: x)

Return array x coerced to two-dimensional array with index sets S1 and S2

function array [int,int] of var $V: array2d(set of int: S1, set of int: S2, array [$U] of var $V: x)

Return array x coerced to two-dimensional array with index sets S1 and S2

function array [int,int] of var opt $V: array2d(set of int: S1, set of int: S2, array [$U] of var opt $V: x)

Return array x coerced to two-dimensional array with index sets S1 and S2

function array [int,int,int] of $V: array3d(set of int: S1, set of int: S2, set of int: S3, array [$U] of $V: x)

Return array x coerced to three-dimensional array with index sets S1, S2 and S3

function array [int,int,int] of var $V: array3d(set of int: S1, set of int: S2, set of int: S3, array [$U] of var $V: x)

Return array x coerced to three-dimensional array with index sets S1, S2 and S3

function array [int,int,int] of var opt $V: array3d(set of int: S1, set of int: S2, set of int: S3, array [$U] of var opt $V: x)

Return array x coerced to three-dimensional array with index sets S1, S2 and S3

function array [int,int,int,int] of $V: array4d(set of int: S1, set of int: S2, set of int: S3, set of int: S4, array [$U] of $V: x)

Return array x coerced to 4-dimensional array with index sets S1, S2, S3 and S4

function array [int,int,int,int] of var $V: array4d(set of int: S1, set of int: S2, set of int: S3, set of int: S4, array [$U] of var $V: x)

Return array x coerced to 4-dimensional array with index sets S1, S2, S3 and S4

function array [int,int,int,int] of var opt $V: array4d(set of int: S1, set of int: S2, set of int: S3, set of int: S4, array [$U] of var opt $V: x)

Return array x coerced to 4-dimensional array with index sets S1, S2, S3 and S4

function array [int,int,int,int,int] of $V: array5d(set of int: S1, set of int: S2, set of int: S3, set of int: S4, set of int: S5, array [$U] of $V: x)

Return array x coerced to 5-dimensional array with index sets S1, S2, S3, S4 and S5

function array [int,int,int,int,int] of var $V: array5d(set of int: S1, set of int: S2, set of int: S3, set of int: S4, set of int: S5, array [$U] of var $V: x)

Return array x coerced to 5-dimensional array with index sets S1, S2, S3, S4 and S5

function array [int,int,int,int,int] of var opt $V: array5d(set of int: S1, set of int: S2, set of int: S3, set of int: S4, set of int: S5, array [$U] of var opt $V: x)

Return array x coerced to 5-dimensional array with index sets S1, S2, S3, S4 and S5

function array [int,int,int,int,int,int] of $V: array6d(set of int: S1, set of int: S2, set of int: S3, set of int: S4, set of int: S5, set of int: S6, array [$U] of $V: x)

Return array x coerced to 6-dimensional array with index sets S1, S2, S3, S4, S5 and S6

function array [int,int,int,int,int,int] of var $V: array6d(set of int: S1, set of int: S2, set of int: S3, set of int: S4, set of int: S5, set of int: S6, array [$U] of var $V: x)

Return array x coerced to 6-dimensional array with index sets S1, S2, S3, S4, S5 and S6

function array [int,int,int,int,int,int] of var opt $V: array6d(set of int: S1, set of int: S2, set of int: S3, set of int: S4, set of int: S5, set of int: S6, array [$U] of var opt $V: x)

Return array x coerced to 6-dimensional array with index sets S1, S2, S3, S4, S5 and S6

function array [$T] of $V: arrayXd(array [$T] of var opt $X: x, array [$U] of $V: y)

Return array y coerced to array with same number of dimensions and same index sets as array x

function array [$T] of var $V: arrayXd(array [$T] of var opt $X: x, array [$U] of var $V: y)

Return array y coerced to array with same number of dimensions and same index sets as array x

function array [$T] of var opt $V: arrayXd(array [$T] of var opt $X: x, array [$U] of var opt $V: y)

Return array y coerced to array with same number of dimensions and same index sets as array x

function array [int] of $T: col(array [int,int] of $T: x, int: c) =
array1d(index_set_1of2(x), [ x[i, c] | i in index_set_1of2(x) ])
(standard decomposition from builtins.mzn:929)

Return column c of array x

function array [int] of var $T: col(array [int,int] of var $T: x, int: c) =
array1d(index_set_1of2(x), [ x[i, c] | i in index_set_1of2(x) ])
(standard decomposition from builtins.mzn:932)

Return column c of array x

function array [int] of var opt $T: col(array [int,int] of var opt $T: x, int: c) =
array1d(index_set_1of2(x), [ x[i, c] | i in index_set_1of2(x) ])
(standard decomposition from builtins.mzn:935)

Return column c of array x

test has_element($T: e, array [int] of $T: x) =
exists ( i in index_set(x) ) ( x[i]==e )
(standard decomposition from builtins.mzn:941)

Test if e is an element of array x

predicate has_element($T: e, array [int] of var opt $T: x) =
exists ( i in index_set(x) ) ( x[i]==e )
(standard decomposition from builtins.mzn:943)

Test if e is an element of array x

test has_index(int: i, array [int] of var opt $T: x) =
i in index_set(x)
(standard decomposition from builtins.mzn:939)

Test if i is in the index set of x

function set of int: index_set(array [int] of var opt $U: x)

Return index set of one-dimensional array x

function set of int: index_set_1of2(array [int,int] of var opt $U: x)

Return index set of first dimension of two-dimensional array x

function set of int: index_set_1of3(array [int,int,int] of var opt $U: x)

Return index set of first dimension of 3-dimensional array x

function set of int: index_set_1of4(array [int,int,int,int] of var opt $U: x)

Return index set of first dimension of 4-dimensional array x

function set of int: index_set_1of5(array [int,int,int,int,int] of var opt $U: x)

Return index set of first dimension of 5-dimensional array x

function set of int: index_set_1of6(array [int,int,int,int,int,int] of var opt $U: x)

Return index set of first dimension of 6-dimensional array x

function set of int: index_set_2of2(array [int,int] of var opt $U: x)

Return index set of second dimension of two-dimensional array x

function set of int: index_set_2of3(array [int,int,int] of var opt $U: x)

Return index set of second dimension of 3-dimensional array x

function set of int: index_set_2of4(array [int,int,int,int] of var opt $U: x)

Return index set of second dimension of 4-dimensional array x

function set of int: index_set_2of5(array [int,int,int,int,int] of var opt $U: x)

Return index set of second dimension of 5-dimensional array x

function set of int: index_set_2of6(array [int,int,int,int,int,int] of var opt $U: x)

Return index set of second dimension of 6-dimensional array x

function set of int: index_set_3of3(array [int,int,int] of var opt $U: x)

Return index set of third dimension of 3-dimensional array x

function set of int: index_set_3of4(array [int,int,int,int] of var opt $U: x)

Return index set of third dimension of 4-dimensional array x

function set of int: index_set_3of5(array [int,int,int,int,int] of var opt $U: x)

Return index set of third dimension of 5-dimensional array x

function set of int: index_set_3of6(array [int,int,int,int,int,int] of var opt $U: x)

Return index set of third dimension of 6-dimensional array x

function set of int: index_set_4of4(array [int,int,int,int] of var opt $U: x)

Return index set of fourth dimension of 4-dimensional array x

function set of int: index_set_4of5(array [int,int,int,int,int] of var opt $U: x)

Return index set of fourth dimension of 5-dimensional array x

function set of int: index_set_4of6(array [int,int,int,int,int,int] of var opt $U: x)

Return index set of fourth dimension of 6-dimensional array x

function set of int: index_set_5of5(array [int,int,int,int,int] of var opt $U: x)

Return index set of fifth dimension of 5-dimensional array x

function set of int: index_set_5of6(array [int,int,int,int,int,int] of var opt $U: x)

Return index set of fifth dimension of 6-dimensional array x

function set of int: index_set_6of6(array [int,int,int,int,int,int] of var opt $U: x)

Return index set of sixth dimension of 6-dimensional array x

test index_sets_agree(array [$T] of var opt $U: x, array [$T] of var opt $W: y)

Test if x and y have the same index sets

function int: length(array [$T] of var opt $U: x)

Return the length of array x

Note that the length is defined as the number of elements in the array, regardless of its dimensionality.

function array [int] of $T: reverse(array [int] of $T: x) =
let {int: l = max(index_set(x))+min(index_set(x)), } in (array1d(index_set(x), [ x[l-i] | i in index_set(x) ]))
(standard decomposition from builtins.mzn:706)

Return the array x in reverse order

The resulting array has the same index set as x.

function array [int] of var $T: reverse(array [int] of var $T: x) =
let {int: l = max(index_set(x))+min(index_set(x)), } in (array1d(index_set(x), [ x[l-i] | i in index_set(x) ]))
(standard decomposition from builtins.mzn:714)

Return the array x in reverse order

The resulting array has the same index set as x.

function array [int] of var opt $T: reverse(array [int] of var opt $T: x) =
let {int: l = max(index_set(x))+min(index_set(x)), } in (array1d(index_set(x), [ x[l-i] | i in index_set(x) ]))
(standard decomposition from builtins.mzn:722)

Return the array x in reverse order

The resulting array has the same index set as x.

function array [int] of $T: row(array [int,int] of $T: x, int: r) =
array1d(index_set_2of2(x), [ x[r, i] | i in index_set_2of2(x) ])
(standard decomposition from builtins.mzn:919)

Return row r of array x

function array [int] of var $T: row(array [int,int] of var $T: x, int: r) =
array1d(index_set_2of2(x), [ x[r, i] | i in index_set_2of2(x) ])
(standard decomposition from builtins.mzn:922)

Return row r of array x

function array [int] of var opt $T: row(array [int,int] of var opt $T: x, int: r) =
array1d(index_set_2of2(x), [ x[r, i] | i in index_set_2of2(x) ])
(standard decomposition from builtins.mzn:925)

Return row r of array x