Add 2

Description

Addition

Source: The Art of Prolog

Download

Program source code: add_2.pl

Listing

/*
	myplus(X,Y,Z) :-
		X, Y and Z are natural numbers
		such that Z is the sum of X and Y.
*/
 
	myplus(0,X,X) :- natural_number(X).
	myplus(s(X),Y,s(Z)):- myplus(X,Y,Z).
 
	natural_number(0).
	natural_number(s(X)) :- natural_number(X).
 
%	Program 3.3: Addition

Comments

pl/prolog/pllib/add_2.txt · ostatnio zmienione: 2019/06/27 15:50 (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