Path: utzoo!yunexus!geac!syntron!jtsv16!uunet!mcvax!ukc!eagle.ukc.ac.uk!jrc From: jrc@ukc.ac.uk (J.R.G.Cupitt) Newsgroups: comp.lang.lisp Subject: Re: permutations Message-ID: <5671@eagle.ukc.ac.uk> Date: 24 Oct 88 02:57:24 GMT Article-I.D.: eagle.5671 References: <1131@amelia.nas.nasa.gov> Reply-To: jrc@ukc.ac.uk (J.R.Cupitt) Organization: Computing Lab, University of Kent at Canterbury, UK. Lines: 22 In article <1131@amelia.nas.nasa.gov> raible@orville.nas.nasa.gov (Eric L. Raible) writes: }(defun permutations (elements) } (if (null elements) } (list nil) } (mapcan } #'(lambda (element) } (mapcar } #'(lambda (permutation) } (cons element permutation)) } (permutations (remove element elements)))) } elements))) } }Comments? Alternatives? Good grief! I almost collapsed when I saw this .. I realise that this is a LISP group, but I can't resist posting the same algorithm in Miranda: perms :: [*] -> [[*]] perms x = [[]], x = [] = [ a:p | a <- x; p <- perms (x--[a]) ], otherwise John Cupitt