1 Prolog Bubblesort 22. März 2006, 17:01 Hier 3 verschiedene Bubblesort Codes für Prolog Quellcode bubblesort(L_In,L_Out):- append(L_Front, [A, B|Rest], L_In), B < A,!, append(L_Front, [B, A|Rest], L_Rest), bubblesort(L_Rest, L_Out). bubblesort(Liste, Liste). Quellcode bubblesort(Xs,Xs):- geordnet(Xs). bubblesort(Xs,Ys):- append(As,[X,Y|Rs],Xs), X>Y, append(As,[Y,X|Rs],Xs1), bubblesort(Xs1,Ys). Quellcode bubble_sort(List,Sorted):-bubblesort(List,[],Sorted). bubblesort([],Acc,Acc). bubblesort([H|T],Acc,Sorted):-bubble(H,T,NT,Max),bubblesort(NT,[Max|Acc],Sorted). bubble(X,[],[],X). bubble(X,[Y|T],[Y|NT],Max):-X>Y,bubble(X,T,NT,Max). bubble(X,[Y|T],[X|NT],Max):-X=<Y,bubble(Y,T,NT,Max).