Add

Description

Multiple uses for plus

Source: The Art of Prolog

Download

Program source code: add.pl

Listing

/*
   myplus(X,Y,Z) :- The sum of the numbers X and Y is Z.
*/
   myplus(X,Y,Z) :- nonvar(X), nonvar(Y), Z is X + Y.
   myplus(X,Y,Z) :- nonvar(X), nonvar(Z), Y is Z - X.
   myplus(X,Y,Z) :- nonvar(Y), nonvar(Z), X is Z - Y.
 
%   Program 10.1   Multiple uses for plus

Comments

pl/prolog/pllib/add.txt · ostatnio zmienione: 2017/07/17 08:08 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0