/ Published in: Lisp
A Functional quick sort (Java imperative version seems to be quicker).
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
(defn qsort-rs [[pivot & xs]] (when pivot (let [smaller #(< % pivot)] (lazy-cat (qsort (filter smaller xs)) [pivot] (qsort (remove smaller xs))))))
URL: http://rosettacode.org/wiki/Quicksort#Clojure