Availability:built-in
once(Goal) :- call(Goal), !.
once/1
can in many cases be replaced with ->/2.
The only difference is how the cut behaves (see !/0). The following two
clauses below are identical. Be careful about the interaction with
;/2. The library(apply_macros)
library defines an inline expansion of once/1,
mapping it to (Goal\send{true};fail)
. Using the full
if-then-else constructs prevents its semantics from being changed when
embedded in a ;/2
disjunction.
1) a :- once((b, c)), d. 2) a :- b, c -> d.