Różnice
Różnice między wybraną wersją a wersją aktualną.
|
|
pl:prolog:pllib:lesseq_operator [2019/06/27 15:50] |
pl:prolog:pllib:lesseq_operator [2019/06/27 15:50] (aktualna) |
| ====== Lesseq operator ====== |
| {{tag>math operators arithmetic}} |
| ===== Description ===== |
| The less than or equal relation. |
| |
| **Source**: The Art of Prolog |
| ===== Download ===== |
| Program source code: {{lesseq_operator.pl}} |
| ===== Listing ===== |
| <code prolog> |
| /* |
| 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 |
| </code> |
| ===== Comments ===== |
| |