Skip to content

Instantly share code, notes, and snippets.

@metric-space
Created August 9, 2015 03:51
Show Gist options
  • Save metric-space/786a34c8e1dff75d9649 to your computer and use it in GitHub Desktop.
Save metric-space/786a34c8e1dff75d9649 to your computer and use it in GitHub Desktop.
clojure version of the quicksort in lyah
;; 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