Functional quick sort


/ Published in: Lisp
Save to your folder(s)

A Functional quick sort (Java imperative version seems to be quicker).


Copy this code and paste it in your HTML
  1. (defn qsort-rs [[pivot & xs]]
  2. (when pivot
  3. (let [smaller #(< % pivot)]
  4. (lazy-cat (qsort (filter smaller xs))
  5. [pivot]
  6. (qsort (remove smaller xs))))))

URL: http://rosettacode.org/wiki/Quicksort#Clojure

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.