prolog: family.pl + family.sx, 10 tests; 5/5 classic programs done
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
This commit is contained in:
24
lib/prolog/tests/programs/family.pl
Normal file
24
lib/prolog/tests/programs/family.pl
Normal file
@@ -0,0 +1,24 @@
|
||||
%% family — facts + transitive ancestor + derived relations.
|
||||
%% Five-generation tree: tom -> bob -> {ann, pat} -> jim, plus tom's
|
||||
%% other child liz.
|
||||
|
||||
parent(tom, bob).
|
||||
parent(tom, liz).
|
||||
parent(bob, ann).
|
||||
parent(bob, pat).
|
||||
parent(pat, jim).
|
||||
|
||||
male(tom).
|
||||
male(bob).
|
||||
male(jim).
|
||||
male(pat).
|
||||
female(liz).
|
||||
female(ann).
|
||||
|
||||
father(F, C) :- parent(F, C), male(F).
|
||||
mother(M, C) :- parent(M, C), female(M).
|
||||
|
||||
ancestor(X, Y) :- parent(X, Y).
|
||||
ancestor(X, Y) :- parent(X, Z), ancestor(Z, Y).
|
||||
|
||||
sibling(X, Y) :- parent(P, X), parent(P, Y), \=(X, Y).
|
||||
Reference in New Issue
Block a user