From 552a469e4ff1a7ee91cbdee3bb817dddf9301772 Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Sat, 17 Jun 2023 16:57:32 +0200 Subject: [PATCH] some working prolog --- heights.pl | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 heights.pl 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!').