->/2 — if-then, and if-then-else
Condition -> TrueGoal Condition -> TrueGoal ; FalseGoal
Condition succeeds, then
TrueGoal will be executed.
If-then implicitly cuts the Condition. Cuts that occur within Condition or TrueGoal will cut back to the head of the parent clause. If Condition fails, then the call to
->/2 fails. The second form, results from the interaction between
Condition -> TrueGoal ; FalseGoal
is actually executed as :
( Condition -> TrueGoal) ; FalseGoal
In this case, FalseGoal will be executed instead of TrueGoal when Condition fails.
Cuts occurring in
cut back to the head of the parent clause.
?- true->write(a). a yes.
?- fail->write(a). no.
?- fail->write(a);write(b). b yes.