Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…


Cannot retrieve contributors at this time

file 20 lines (17 sloc) 0.554 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
;; Not so good quick sort
(defn qsort [lst]
  (if (nil? lst)
     (qsort (filter (partial > (first lst)) (rest lst)))
     (list (first lst))
     (qsort (filter (partial <= (first lst)) (rest lst))))))

(defn bubble [lst]
  (if (or (nil? lst) (nil? (second lst)))
    (if (> (first lst) (second lst))
      (lazy-cons (second lst) (lazy-cons (first lst) (bubble (nthrest lst 2))))
      (lazy-cons (first lst) (bubble (rest lst))))))

;; Bubble sort
(defn bubble-sort [lst]
   (last (take (count lst) (iterate bubble lst))))
Something went wrong with that request. Please try again.