Need to know what are these L1
, [H1 | L2]
. No idea at all.
bubSort([],[]) :- !.
bubSort([H],[H]) :- !.
bubSort(L,SL) :- append(L1, [H1,H2|L2], L), H2 < H1, append(L1, [H2,H1|L2], NL), !,
bubSort(NL,SL).
bubSort(L,L).
This compiles and sorts the list well. But I need to understand this mechanism.
Specially the how this append
works.