| causes that one goal implicates alternative goals.
+IfGoal -> +ThenGoal; +ElseGoal
;((IfGoal-> +ThenGoal), +ElseGoal)
If IfGoal succeeds then ThenGoal will be executed.
If IfGoal fails ElseGoal will be executed.
'->'/2 succeeds if either ThenGoal or ElseGoal succeeds.
There are two significant differences to ','/2:
- IfGoal can succeed only once.
- If IfGoal has subgoals and also a Cut ('!'/0)
this Cut has no effect outside of IfGoal.
';'/2 is a predefined infix-operator with priority 1100 which
is right-associative,
'->'/2 is a predefined infix-operator with priority 1050
which is right-associative (see also current_op/3).
Arguments
IfGoal goal
ThenGoal goal
ElseGoal goal
Examples
| Day=sunny -> Weather=sunshine; Weather=raining. |
Succeeds. |
| X=b, X=a -> write(a); write(b). |
Succeeds with substitution X <- b
and outputs to the current outputstream 'b'. |
Standard
This predicate is part of the ISO-Prolog Standard.
See also
abort/0,
break/0,
call/1,
fcall/1,
catch/3,
','(conjunction)/2,
'!'(cut)/0,
';'(disjunction)/2,
fail/0,
true/0,
halt/0/1,
'->'(if-then)/2,
'\+'(not provable)/1,
once/1,
repeat/0,
throw/1.
|