Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 5/3/83; site ukc.UUCP Path: utzoo!watmath!clyde!burl!mgnetp!ihnp4!houxm!houxz!vax135!ukc!srlm From: srlm@ukc.UUCP (S.R.L.Meira) Newsgroups: net.sources,net.lang.c Subject: Re: Stupid-sort -- an O(n*n!) sort program Message-ID: <4322@ukc.UUCP> Date: Tue, 24-Jul-84 05:45:11 EDT Article-I.D.: ukc.4322 Posted: Tue Jul 24 05:45:11 1984 Date-Received: Thu, 19-Jul-84 02:42:37 EDT References: <2897@utah-cs.UUCP> Organization: Computing Lab. Kent University, England Lines: 33 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@ucl-cs Post: computing laboratory university of kent at canterbury canterbury ct2 7nf uk Phone: +44 227 66822 extension 568 *********************************************