Skip to content

Instantly share code, notes, and snippets.

@j1n3l0
Last active December 15, 2015 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save j1n3l0/5323036 to your computer and use it in GitHub Desktop.
Save j1n3l0/5323036 to your computer and use it in GitHub Desktop.
(defn qsort-simple
"Quicksort - the simple algorithm"
[[pivot & tail :as coll]]
(if (> 2 (count coll))
coll
(let [less (filter (partial >= pivot) tail)
more (filter (partial < pivot) tail)]
(concat (qsort-simple less) [pivot] (qsort-simple more)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment