{ A1, ..., An } (1)where each element can be of any type. The type for the array elements will be the least-upper bound of the types of the elements.
The other way for constructing an anonymous array is to use a set expression as follows:
array(Exp,Enumerator,...,Enumerator) (2)where Exp is an expression, and Enumerator is a domain constraint in the form v in D or a relational constraint. Let Vars be the set of variables appearing in all the enumerators. For each tupe of values for Vars that satisfies the enumerators, Exp has a value. This expression represents an array of all such values.
Anonymous arrays can be constructed recursively. Each Ai in (1) and the Exp in (2) can be another array expression.
Let a be a one-dimensional array and b be a two-dimensional array. Consider the following three anonymous arrays:
array(a[i], i in 0..a.length-1) array(b[i][j], i in 0..b.length-1, j in 0..b[i].length-1) array(array(b[i][j], j in 0..b[i].length-1), i in 0..b.legnth-1)The first is a clone of a; the second expression converts b into a one-dimensional anonymous array; and the third expression represents a clone of b.
Anonymous arrays can be used only as arguments of constraints. To the definition side of constraints, anonymous arrays are just the same as usual arrays. Let a be a one-dimensional array of Buttons:
dj Button a[4];and p be a constraint over arrays of the Buttons. Then the following three constraints are equivalent:
p(a) p({a[0], a[1], a[2], a[3]}) p(array(a[i], i in 0..a.length-1))