Quick actions

cmd+k|ctrl+k

Navigation

Languages

quicksort

Snippet info

Language

Clojure

Visibility

public

Author

yoneda

Created

2018-09-27T10:45:15Z

Updated

2018-09-27T12:06:16Z

(defn quick-sort [xs]
    (if (empty? xs)
        []
        (let [head (first xs) tail (rest xs)]
            (concat
                (quick-sort (filter #(<= % head) tail))
                [head]
                (quick-sort (filter #(> % head) tail))))))

(let [xs (sort-by rand (range 1 20))]
    (println xs)
    (println (quick-sort xs)))
INFO