Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -1,17 +1,9 @@
(ns bogosort
(:use [clojure.contrib.seq-utils :only (shuffle)]))
(defn in-order? [less xs]
(defn in-order? [order xs]
(or (empty? xs)
(empty? (next xs))
(and (less (first xs) (second xs))
(recur less (next xs)))))
(apply order xs)))
(defn bogosort
([xs]
(bogosort < xs))
([less xs]
(if (in-order? less xs) xs
(recur less (shuffle xs)))))
(defn bogosort [order xs]
(if (in-order? order xs) xs
(recur order (shuffle xs))))
(println (bogosort [7,5,12,1,4,2,23,18]))
(println (bogosort < [7 5 12 1 4 2 23 18]))