All pastes #369019 Raw Edit

Stuff

public text v1 · immutable
#369019 ·published 2007-02-23 14:50 UTC
rendered paste body
(* qsort  does not work :D *)

<%~O2/#_0#_1%>; (* because / does not work, dunno why *)

fun Q :3: {
	i=_[1];
	j=_[2];
	x = _[0][O((i+j),2)];
	while i < j : {
		while _[0][i] < x : i=i+1;
		while _[0][j] > x : j=j-1;
		if i<=j : {
			t = _[0][i];
			_[0][i] = _[0][j];
			_[0][j] = t;
			i=i+1; 
			j=j+1
		}
	};
	if _[1] < j : Q(_[0],_[1],j);
	if _[1] < i : Q(_[0],i,_[2])
};
q = [2,1,4,3,10,7];
out Q(q,0,@q-1)


(* {SADOL2}

~O2/#_0#_1~Q3(6:i#_1:j#_2:x##_0O+ij2@<ij(3@<##_0ix:i+i1@>##_0jx:j-j1?|<ij=ij(5:t##_0i:##_0i##_0j:##_0jt:i+i1:j+j10?<#_1jQ#_0#_1j0?<#_1iQ#_0i#_20:q$62143,2107!Qq0-#q-011

*)