Skip to content

List-subtraction is explained in manual but does not exist.

The CIF manual (Chapter: Types and values, Section: Lists) explains that:

Several other standard operators and functions are available to work with lists, including the following:

[1, 4, 2, 4, 5] - [2]           // [1, 4, 4, 5] (removal of elements)
[1, 4, 2, 4, 5] - [4]           // [1, 2, 4, 5]
[1, 4, 2, 4, 5] - [8]           // [1, 4, 2, 4, 5]
[1, 2, 3, 4, 5] - [6, 4, 2, 3]  // [1, 5]
[1, 4, 4, 1, 1] - [1, 4, 1]     // [4, 1]

However, the following CIF model gives errors:

alg list int x1 = [1, 4, 2, 4, 5] - [2];

Error:

Binary operator "-" can not be applied to values of type "list[5] int[1..5]" and "list[1] int[2..2]".

Options:

  • Remove this part from the manual.
  • Implement Binary operator "-" for lists.