commit 552a469e4ff1a7ee91cbdee3bb817dddf9301772 Author: PlexSheep Date: Sat Jun 17 16:57:32 2023 +0200 some working prolog diff --git a/heights.pl b/heights.pl new file mode 100644 index 0000000..f659160 --- /dev/null +++ b/heights.pl @@ -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!').