[~/public_html/8710/f98][7:57pm] script prolog-script.html
Script started on Thu Sep 03 19:58:39 1998
[~/public_html/8710/f98][7:58pm] cprolog
C-Prolog version 1.5
| ?- ['qsort.pro'].
qsort.pro consulted 712 bytes 1.78814e-08 sec.
yes
| ?- qsort([2,1,5,4,9,8,5,6,7],L).
L = [1,2,4,5,5,6,7,8,9] ;
no
| ?- halt.
[ Prolog execution halted ]
[~/public_html/8710/f98][7:59pm] cat qsort.pro
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).
[~/public_html/8710/f98][7:59pm] logout
script done on Thu Sep 03 19:59:31 1998