Created
August 9, 2015 03:51
-
-
Save metric-space/786a34c8e1dff75d9649 to your computer and use it in GitHub Desktop.
clojure version of the quicksort in lyah
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
;; definitely slow | |
(defn quicksort [unsorted] | |
(if (empty? unsorted) | |
unsorted | |
(let [pivot (first unsorted) | |
left (filter #(< % pivot) (next unsorted)) | |
right (filter #(> % pivot) (next unsorted)) | |
] | |
(concat (quicksort left) [pivot] (quicksort right)) | |
))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment