3 ms·
Exactly. If you provide a collection, the system will deduce that you want all solutions to be extracted, while if you provide a non collection variable then it
by clauderoux 7y ago
Exactly. If you provide a collection, the system will deduce that you want all solutions to be extracted, while if you provide a non collection variable then it will stop once one solution has been found.
Actually, I have a very specific type, which is "predicatevar", if you want to get your unification once.
?X is actually a true Prolog variable that can be unified over and over again. Furtheremore, you can call Tamgu functions from your predicate description, in which these variables can be used if they are unified.
grandparent(?X,?Y) :- parent(?X,?Z), println(?Z), parent(?Z,?Y).
In the case above, the "println", which is not a predicate, will try to display the content of ?Z, if ?Z has been unified.
println could be replaced with a call to an actual function, as long as this function returns true. If the function returns false, then it will be considered as a fail.