Availability:built-in
If -> Then; _Else :- If, !, Then. If -> _Then; Else :- !, Else. If -> Then :- If, !, Then.
Please note that (If ->
Then) acts as (If ->
Then ;
fail), making the construct fail if the condition fails.
This unusual semantics is part of the ISO and all de-facto Prolog
standards.
Please note that (if->
then;else) is read as ((if->
then);else)
and that the combined semantics of this syntactic construct as
defined above is different from the simple nesting of the two
individual constructs, i.e., the semantics of
->/2 changes
when embedded in ;/2. See
also
once/1.
As with ;/2, this construct is always nested in parenthesis. Here is an example of the preferred layout for SWI-Prolog.
p :- a, ( b, c -> d, e ; f -> g ; h ).