[Next] [Up] [Previous] [Contents] [Index]
Next: Constraints Up: Suspension and attributed variables Previous: Suspension and attributed variables   Contents   Index

Example:


[IMAGE png]

The following example shows how to attach a finite-domain to a variable:

       create_fd_variable(X,D):-
           put_attr(X,fd,D),
           check_value(X,D).
      
       check_value(X,D),var(X),{ins(X)} => true.
       check_value(X,D) => member(X,D).
The agent check_value(X,D) is activated to check whether the value is in the domain when X is instantiated. This predicate can be defined equivalently as follows:
       create_fd_variable(X,D):-
           put_attr_with_hook(X,fd,D).
      
       attr_unify_hook(X,fd,D):-member(X,D).


[IMAGE png]



Neng-Fa Zhou () 2007-06-05