some working prolog
This commit is contained in:
commit
552a469e4f
|
@ -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!').
|
Loading…
Reference in New Issue