Collections functions

Collections functions define ordered or unordered collections of elements (sets, lists and permutations), and let users query their content.

The following functions are available:

See also

See Constraint Programming functions for a general explanation on how to read the signature tables below.


set

Declares a set variable: an unordered collection of distinct integers within the range [1, Argument 1].

Parameters

Parameter

Description

Requirement

Argument 1

Positive integer constant.

Mandatory


list

Declares a list variable: an ordered collection of distinct integers (a subpermutation) within the range [1, Argument 1].

Parameters

Parameter

Description

Requirement

Argument 1

Positive integer constant.

Mandatory


permutation

Declares a permutation variable: an ordered collection of distinct integers (a permutation) within the range [1, Argument 1]. The list contains all the integers in the range, and each integer appears exactly once.

Parameters

Parameter

Description

Requirement

Argument 1

positive integer constant

Mandatory


indexOf

Returns the position of a given value within a list or permutation, or -1 if the value is not present. The second argument could be a list or a permutation or an array to return the array of positions of the values in the first argument.

Parameters

Signature 1

Parameter

Description

Requirement

Argument 1

list or permutation

Mandatory

Argument 2

numeric (dimension 0)

Mandatory

Signature 2

Parameter

Description

Requirement

Argument 1

list or permutation

Mandatory

Argument 2

array of integers of dimension 1, list

Mandatory


find

Returns the position of the first collection, within an array of collections, that contains the given element, or -1 if no such collection exists. The second argument could be a list or a permutation or an array to return the array of index of collections containing the given element.

Parameters

Signature 1

Parameter

Description

Requirement

Argument 1

collection (of a consistent element type)

Mandatory

Argument 2

numeric (dimension 0)

Mandatory

Signature 2

Parameter

Description

Requirement

Argument 1

collection (of a consistent element type)

Mandatory

Argument 2

array of integers of dimension 1, list

Mandatory