Author: Tord Romstad
Date: 13:29:06 10/20/99
Go up one level in this thread
On October 20, 1999 at 16:18:11, Tord Romstad wrote: >A Common Lisp implementation of the second algorithm suggested: > >(defun generate-all-permutations (list) > (cond > ((<= (length list) 1) (list list)) > (t (apply #'append > (let ((permutations nil)) > (dolist (elt list permutations) > (push (mapcar #'(lambda (l) (cons elt l)) > (generate-all-permutations > (remove elt list :count 1))) > permutations))))))) > >(defun sorted-p (list) > (apply #'< list)) > >(defun bogosort (list comparison-p) > (let ((permutations (generate-all-permutations list))) > (find-if #'sorted-p permutations))) Arrgh. 'comparison-p' is never used and should of course be removed. The code above only works for lists of numbers. I is obviously time to go to bed... Tord
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.