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

<ConsistencyModule:> mem(+Vars,?Member)

Constrains Member to be the a member element in Vars.
Vars
Collection (a la collection_to_list/2) of (domain) variables or integers (NOT arbitrary expressions)
Member
Member element of Vars (domain variable or integer, array notation accepted)

Description

Constrains Member to be a one of the elements in Vars.

Note that this constraint has the same declarative semantics as the standard member/2 predicate, but the order of the arguments are reversed to allow the constraint to be used in constraint expressions.

You may find it more convenient to embed mem(Vars) in a constraint expression.

This constraint is implemented by Gecode's member() constraint.

ConsistencyModule is the optional module specification to give the consistency level for the propagation for this constraint: gfd_gac for domain (generalised arc) consistency.

Examples

[eclipse 7]: A :: 1..10, B :: 2..20, mem([A,B], M).

A = A{[1 .. 10]}
B = B{[2 .. 20]}
M = M{[1 .. 20]}


[eclipse 8]: A :: 1..10, B :: 2..20, mem([A,B], M), M #< 5.

A = A{[1 .. 10]}
B = B{[2 .. 20]}
M = M{[1 .. 4]}


[eclipse 9]: A :: 1..10, B :: 2..20, mem([A,B], M), M #< 2.

A = A{[1 .. 10]}
B = B{[2 .. 20]}
M = 1

[eclipse 10]: mem([4,5,5,4,1,5], C).

C = C{[1, 4, 5]}


See Also

mem / 3, eclipse_6 : collection_to_list / 2, lists : collection_to_list / 2