Sorting algorithms/Bogosort: Difference between revisions
Content added Content deleted
(VBScript entry) |
(→{{header|Clojure}}: small improvements; add example) |
||
Line 347: | Line 347: | ||
We use seq-utils' shuffle, which initializes a Java ArrayList with the input sequence, shuffle it, and then return a sequence of the result. |
We use seq-utils' shuffle, which initializes a Java ArrayList with the input sequence, shuffle it, and then return a sequence of the result. |
||
<lang clojure>(ns bogosort |
|||
(:use [clojure.contrib.seq-utils :only (shuffle)])) |
|||
(defn in-order? [ |
(defn in-order? [less xs] |
||
(or (empty? xs) |
(or (empty? xs) |
||
(empty? (next xs)) |
(empty? (next xs)) |
||
(and ( |
(and (less (first xs) (second xs)) |
||
(recur |
(recur less (next xs))))) |
||
(defn bogosort |
|||
([xs] |
|||
(bogosort < xs)) |
|||
([less xs] |
|||
⚫ | |||
⚫ | |||
( |
(println (bogosort [7,5,12,1,4,2,23,18]))</lang> |
||
⚫ | |||
⚫ | |||
=={{header|Common Lisp}}== |
=={{header|Common Lisp}}== |