The second clause in the predicate occured_once/2 relies on the behavior of
member/2 in that if the list contains an unbound variable, it counts as an
occurrance, e.g.,

 | ?- member( 1, [2,X]).

 X = 1 ?

 yes

If an unbound variable is an element of the list, then the variable can
unify with operand one and occurs, e.g.,

 | ?- occured_once(1, [V]).

 V = 1 ?

 yes


If more than one unbound variable is an element of the list, then the
occured_once predicate will always fail, e.g.,

 | ?- occured_once(1, [V,W]).

 no

The example is even more interesting when using structures,

 | ?- occured_once( v(c(1)), [ v(2), v(c(X)) ]).

 X = 1 ?

 yes


more,
l8r,
v
_______________________________________________
Users-prolog mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/users-prolog

Reply via email to