%% -------------------------------------- %% Some information about the Bush family. %% -------------------------------------- mother(barbara, georgejr). father(georgejr, jenna). father(georgejr, barbara2). parent(X,Y) :- mother(X,Y). parent(X,Y) :- father(X,Y). grandmother(X,Z) :- mother(X,Y), parent(Y,Z), write('Solution = '), write(Z), nl, fail. % ------------------------- % A definiton for factorial. % ------------------------- factorial(0,1). factorial(N,A) :- N > 0, N1 is N - 1, factorial(N1,B), A is N * B. % ------------------------------------------------ % Counting the number of top level items in a list. % ------------------------------------------------ count([],0). count([A|B],N) :- count(B,X), N is 1 + X. % ----------------------- % A definition for append. % ----------------------- myappend([], X, X). myappend([X|Y], Z, [X|W]) :- myappend(Y,Z,W).