8 lines
No EOL
231 B
Prolog
8 lines
No EOL
231 B
Prolog
bubbleup([X, Y|L], [Y, X|L]) :- X > Y.
|
|
bubbleup([Z|L], [Z|ZL]) :- bubbleup(L, ZL).
|
|
|
|
bubblesort([], []).
|
|
bubblesort(L, SL) :- bubbleup(L, ZL), !, bubblesort(ZL, SL).
|
|
bubblesort(SL, SL).
|
|
|
|
?-bubblesort([7,9,1,2,3,6,4,5,8,0], SL). |