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

exclude(?Var, ++Excl)

Exclude the element Excl from the domain of Var.
Integer variable or integer
Integer value to exclude


Primitive for excluding an element from the domain of an integer variable. The call may fail (when Var is the same integer as Excl), succeed (possibly updating the variable's domain), or instantiate the variable (when Excl was one of only two domain elements left).

Note that this predicate is intended for use only in implementing constraint propagators, and should not be called from ordinary user code (use ic:(Var =\= Excl) instead). It differs from the usual constraint predicates with respect to the execution of delayed goals. If the call to exclude/2 results in a domain change, any delayed goals suspended on that change will be scheduled for execution, as normal. However, exclude/2 does not call the woken goal scheduler (wake/0), so these goals may not be executed immediately. (It is possible that under some circumstances the goals will be executed, if wake/0 is called indirectly - one example would be by the unify handler if the variable becomes ground - but this should not be relied upon.) To ensure that the goals are eventually executed, the caller should arrange for wake/0 to be called at some appropriate point in the subsequent execution. Please see the "Advanced Control Features" section of the User Manual for more information about woken goal management.


[eclipse 3]: X :: 0..10, exclude(X, 4).
X = X{[0 .. 3, 5 .. 10]}
Yes (0.00s cpu)

[eclipse 4]: X :: [4, 6], exclude(X, 4).
X = 6
Yes (0.00s cpu)

See Also

exclude_range / 3, impose_min / 2, impose_max / 2, impose_domain / 2