ex5: init prolog

This commit is contained in:
2025-11-04 17:25:36 +01:00
parent abd778584b
commit 51b98487fe
4 changed files with 30 additions and 0 deletions

1
assignment5/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
ass5.pdf

9
assignment5/Makefile Normal file
View File

@@ -0,0 +1,9 @@
PROLOG = swipl
.PHONY: run clean
all: run/main.pl
run/%:
@$(PROLOG) -f $* -t halt -q
consult/%:
@$(PROLOG) -f $* -q
clean:
rm -f *.qlf

19
assignment5/test.pl Normal file
View File

@@ -0,0 +1,19 @@
parent(tom, bob).
parent(tom, liz).
parent(bob, ann).
parent(bob, pat).
parent(pat, jim).
grandparent(X, Z) :- parent(X, Y), parent(Y, Z).
ancestor(X, Y) :- parent(X, Y).
ancestor(X, Y) :- parent(X, Z), ancestor(Z, Y).
:- initialization(main).
main :-
write('Grandparents of jim: '),
findall(X, grandparent(X, jim), Grandparents),
write(Grandparents), nl,
write('Ancestors of jim: '),
findall(X, ancestor(X, jim), Ancestors),
write(Ancestors), nl.

View File

@@ -18,6 +18,7 @@
sbt
scala
scalafmt
swi-prolog
];
shellHook = ''
echo "enjoy m*oz*art2"