once(
Goal)
We have seen that
\+ Goal
and
( Goal -> false ; true )
have the same effect. The form
( Goal -> true ; false )
is also useful: it commits to the first solution of Goal.
This operation has a name:
once Goal
once/1
is useful when you have a nondeterminate definition for Goal, but in
this case you want to solve it determinately. For example, to find out if
there are any married couples, you could use
once married(_, _)
If the predicate is really determinate in concept, it is better to make it
determinate in definition as well, rather than to use once/1
.