Towers of Hanoi --------------- hanoi(N) :- nl, nl, move(N,left,centre,right). move(0,_,_,_) :- !. move(N,A,B,C) :- M is N - 1, move(M,A,C,B), inform(A,B), move(M,C,B,A). inform(X,Y) :- write('move disc from '),write(X),write(' pole to the '), write(Y),write(' pole.'),nl. Quicksort --------- split(H,[A|X],[A|Y],Z) :- A =< H, split(H,X,Y,Z). split(H,[A|X],Y,[A|Z]) :- A > H, split(H,X,Y,Z). split(_,[],[],[]). qsort([],[]). qsort([H|T],S) :- split(H,T,A,B), qsort(A,A1), qsort(B,B1), append(A1,[H|B1],S). append([],L,L). append([H|T],L,[H|V]) :- append(T,L,V).