-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= an example code for Prolog -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= klim@moose:~/tmp> gprolog GNU Prolog 1.3.0 By Daniel Diaz Copyright (C) 1999-2007 Daniel Diaz | ?- [pp]. compiling /home/klim/tmp/pp.pl for byte code... /home/klim/tmp/pp.pl compiled, 25 lines read - 2165 bytes written, 17 ms yes | ?- father(terach,issac). +-------------------------------+ | father(terach, abraham). | no | father(terach, nachor). | | ?- father(terach,haran). | father(terach, haran). | | | yes | father(haran,lot). | | ?- father(terach,X). | father(haran,milcah). | | father(haran,yiscah). | X = abraham ? ; | | | mother(sarah, isaac). | X = nachor ? ; | | | male(terach). | X = haran | male(abraham). | | male(nachor). | yes | male(haran). | | ?- father(X,abraham). | male(isaac). | | male(lot). | X = terach ? ; | male(sarah). | | male(yiscah). | no | | | ?- father(X,Y). | parent(X,Y) :- father(X,Y). | | parent(X,Y) :- mother(X,Y). | X = terach | | Y = abraham ? ; | son(X,Y) :- | | parent(Y,X), male(X). | .......................... | daughter(X,Y) :- | | parent(Y,X), female(X). | yes +-------------------------------+ | ?- parent(X,nachor). X = terach ? ; no | ?- append([1], [2,3], X). +-------------------------------+ | append([], X, X). | X = [1,2,3] | append([X|Xs], Y, [X|Z]) :- | | append(Xs, Y, Z). | yes +-------------------------------+ | ?- append(X,Y,[1,2,3]). X = [] Y = [1,2,3] ? ; X = [1] Y = [2,3] ? ; X = [1,2] Y = [3] ? ; X = [1,2,3] Y = [] ? ; no | ?-