このディレクトリの索引
%% TECHINIQUES OF PROLOG PROGRAMMING by T. Van Le, ph D.  %%

sort_list(L,L1) :- quick_sort(L,[],L1).

quick_sort([],R,R).
quick_sort([H|T],R,L1) :-
    partition(T,Lt,H,Gt),
    quick_sort(Gt,R,GtsR),
    quick_sort(Lt,[H|GtsR],L1).

partition([],[],_,[]).
partition([H|T],[H|TLt],X,Gt) :-
    H =< X,partition(T,TLt,X,Gt).
partition([H|T],Lt,X,[H|TGt]) :-
    H > X, partition(T,Lt,X,TGt).