Files
sandbox/lpn/ch03/descend.pl
Kyle Isom 6d4fb673ef LPN: reorg, split notes from exocortex page.
The exocortex page was getting unwieldy, this makes more sense.
2018-01-16 16:43:12 -08:00

24 lines
461 B
Prolog

%% facts
child(anne,bridget).
child(bridget,caroline).
child(caroline,donna).
child(donna,emily).
%% rules
descend(X,Y) :- child(X,Y).
descend(X,Y) :- child(X,Z),
descend(Z,Y).
descend1(X,Y) :- child(X,Y).
descend1(X,Y) :- child(X,Z),
descend1(Z,Y).
descend2(X,Y) :- child(X,Y).
descend2(X,Y) :- descend2(Z,Y),
child(X,Z).
%% WARNING: non-terminating.
descend3(X,Y) :- child(X,Y).
descend3(X,Y) :- descend3(X,Z),
descend3(Z,Y).