Stupid-sort -- an O(n*n!) sort program

S.R.L.Meira srlm at ukc.UUCP
Tue Jul 24 19:45:11 AEST 1984


	it is a lot easier to understand what is going on,
	and by the way more efficient (!) although still terrible,
	if you choose the right sort of language. look at the
	same thing in krc (kent recursive calculator), a purely
	applicative, non-strict, higher order language we use
	over here:

	ordered [] = true
	ordered [a] = true
	ordered (a:b:x) = a <= b & ordered (b:x)

	perms [] = [[]]
	perms x = { a:y | a <- x ; y <- perms (x -- [a]) }

	perm_sort x = head (filter ordered (perms x))

	i think it is all self-explanatory (of course). for details,
	mail me in the address below.


	*********************************************
	silvio lemos meira

	UUCP: 	...!{vax135,mcvax}!ukc!srlm
	ARPA:	srlm%eagle at ucl-cs
	Post:
		computing laboratory
		university of kent at canterbury
		canterbury ct2 7nf uk
	Phone:
		+44 227 66822 extension 568
	*********************************************



More information about the Comp.lang.c mailing list