11.3.101 if/3



If P then Q else R, for all solution of P.


callable, must be nonvar
callable, must be nonvar
callable, must be nonvar


Analogous to

     if P then Q else R

but differs from P -> Q ; R in that if(P, Q, R) explores all solutions to the goal P. There is a small time penalty for this—if P is known to have only one solution of interest, the form P -> Q ; R should be preferred.

This is normally regarded as part of the syntax of the language, but it is like a built-in predicate in that you can write call(if(P,Q,R)).

Cuts in P do not make sense, but they are allowed, their scope being the goal P. The scope of cuts in Q and R extends to the containing clause.


Depends on the arguments.


Call errors (see ref-sem-exc).

See Also


Send feedback on this subject.