Created
August 18, 2010 20:37
-
-
Save dakrone/536105 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn large-quicksort | |
[items] | |
(if (<= (count items) 1) | |
items | |
(let [pindex (rand-int (count items)) | |
p (get (vec items) pindex) | |
[before after-with-p] (split-at pindex items) | |
after (rest after-with-p) | |
newitems (vec (concat before after))] | |
#(concat | |
(large-quicksort (filter (fn [i] (< i p)) newitems)) | |
[p] | |
(large-quicksort (filter (fn [i] (>= i p)) newitems)))))) | |
(println (trampoline (large-quicksort [3 7 8 5 2 1 9 6 4]))) | |
user=> (trampoline (large-quicksort [3 7 8])) | |
( | |
#<RuntimeException java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: user$large_quicksort$fn__1796> |
zk
commented
Aug 19, 2010
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment