Sorting algorithms/Bogosort: Difference between revisions

Content added Content deleted
(added a Common Lisp solution)
Line 339: Line 339:
=={{header|Common Lisp}}==
=={{header|Common Lisp}}==


Sortedp checks that each element of a list is related by predicate to the next element of the list. I.e., (sortedp (x1 x2 ... xn) pred) is true when each of pred(x1,x2), ..., pred(xn-1,xn) is true.
Sortedp checks that each element of a list is related by predicate to the next element of the list. I.e., <code>(sortedp (x<sub>1</sub> x<sub>2</sub> x<sub>n</sub>) pred)</code> is true when each of <code>(pred x<sub>1</sub> x<sub>2</sub>)</code>, , <code>(pred x<sub>n-1</sub> x<sub>n</sub>)</code> is true.


<lang lisp>(defun shuffle (list)
<lang lisp>(defun shuffle (list)