Spis treści

If then

Description

If-then-else statement

Source: The Art of Prolog

Download

Program source code: if_then.pl

Listing

/*
   if_then_else(P,Q,R) :- Either P and Q, or not P and R.
*/
     if_then_else(P,Q,R) :- P, !, Q.
     if_then_else(P,Q,R) :- R.
 
%   Program 11.10    If-then-else statement

Comments