some working prolog

This commit is contained in:
Christoph J. Scherr 2023-06-17 16:57:32 +02:00
commit 552a469e4f
Signed by: PlexSheep
GPG Key ID: 25B4ACF7D88186CC
1 changed files with 13 additions and 0 deletions

13
heights.pl Normal file
View File

@ -0,0 +1,13 @@
/* facts */
set_height(dave, 180).
set_height(alice, 155).
set_height(bob, 176).
set_height(mary, 166).
set_height(phi, 166).
set_height(tom, 32).
/* rules */
taller_than(X, Y) :- set_height(X, XH), set_height(Y, YH), XH < YH.
smaller_than(X, Y) :- set_height(X, XH), set_height(Y, YH), XH > YH.
same_height(X, Y) :- set_height(X, XH), set_height(Y, YH), XH = YH.
size(X) :- set_height(X, XH), write(X), write(' is '), write(XH), write(' cm tall!').