Lesseq operator

Description

The less than or equal relation.

Source: The Art of Prolog

Download

Program source code: lesseq_operator.pl

Listing

/*
	X lesseq Y :-  X and Y are natural numbers,
	  		  such that X is less than or equal to Y.
 
We use lesseq to represent the operator rather than cause problems
with an error message from Prolog about redefining an operator!
*/
 
	:- op(40,xfx, 'lesseq').
	0 lesseq X :- natural_number(X).
	s(X) lesseq s(Y) :- X lesseq Y.
 
	natural_number(0).
	natural_number(s(X)) :- natural_number(X).
 
%	Program 3.2: The less than or equal relation

Comments

pl/prolog/pllib/lesseq_operator.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