Talk:Bubble sort

From CodeCodex

Strange error[edit]

Upon clicking on this article, I was barraged with little 'notices' about some error in the coding of the page. Something about some code beautifier. there were literally hundreds of the things at the top of the page. I believe the problem was caused by the highlight syntax tag, as replacing it with the pre html tag seems to have corrected the problem. Just thought I'd point this out.

(If you want to see the notices in question, just go back to the version of the page directly before mine in the page's history). --Why My Fleece? 04:00, 12 August 2007 (CDT)


And confusingly, after looking through Daxim's contributions, other pages which he added the HIGHLIGHTSYNTAX tag to have not been affected in this way. :/

So I don't have a clue what caused those notices. :( --Why My Fleece? 04:10, 12 August 2007 (CDT)

C++[edit]

C++ version isn't bubble sort at all.

C[edit]

a C implementation is not given, but it's referred to in the C++ part.

Prolog[edit]

domains
	elem = integer
	list = elem*
predicates
	swapAll(list, list)
	isSorted(list)
	bubble(list, list)
clauses
	swapAll([H|[]], [H]):-!.
	swapAll([H1,H2|T], [H2|R]):-
		H1 > H2,
		!,
		swapAll([H1|T], R).
	swapAll([H|T], [H|R]):-
		swapAll(T, R).
	
	isSorted([]):-!. %list with no elements is sorted
	isSorted([_|[]]):-!. %list with 1 element is sorted
	isSorted([H1,H2|L]):-
		H1 < H2,
		isSorted([H2|L]).
	
	bubble(L, L):-
		isSorted(L), !.
	bubble(L, R):-
		swapAll(L, L2),
		bubble(L2, R).