Create a gist now

Instantly share code, notes, and snippets.

(ns adaa)
(defn merger
[a b c]
(if (every? empty? [a b])
(empty? a) (merger a (rest b) (conj c (first b)))
(empty? b) (merger (rest a) b (conj c (first a)))
:else (if (< (first a) (first b))
(merger (rest a) b (conj c (first a)))
(merger a (rest b) (conj c (first b)))))))
(defn merge-sort
(let [n (count coll) m (/ n 2)]
(if (<= n 1)
(merger (merge-sort (take m coll)) (merge-sort (drop m coll)) []))))

My first pass at merge sort. Causes a stack overflow at around n = 4000 ... so not very good :( Looking at this gist now for inspiration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment