[ library(gfd) | Reference Manual | Alphabetic Index ]

precede(+S, +T, +Collection)

Constrains S to precede T in Collection
S
Integer
T
Integer
Collection
Collection of integers or (domain) variables

Description

Constrains the first appearance of value S to precede the first appearance of value T in the ordered collection of elements in Collection. S and T do not have to appear in Collection: if only S appears, the constraint will succeed, and if only T appears, the constraint will fail. If neither appears, the constraint will succeed.

This constraint is known as int_value_precede in the Global Constraint Catalog, and is implemented using Gecode's precede() constraint (variant with int arguments for s and t).

Examples

[eclipse 14]: precede(0,1, [4,0,6,1,0]).  % succeed (0 appears before 1)

[eclipse 15]: precede(0,1, [](4,0,6,1,0)). % succeed (0 appears before 1)

[eclipse 16]: precede(0,1, [A,B,C,D,E]).

A = A{[-1000000 .. 0, 2 .. 1000000]}
B = B{[-1000000 .. 1000000]}
C = C{[-1000000 .. 1000000]}
D = D{[-1000000 .. 1000000]}
E = E{[-1000000 .. 1000000]}

[eclipse 17]:  precede(0,1, [4,1,6,0,0]).   % fail (1 appears before 0)

See Also

precede / 2, eclipse_6 : collection_to_list / 2, lists : collection_to_list / 2