Skip to content

Instantly share code, notes, and snippets.

@Deraen
Last active August 29, 2015 14:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Deraen/cb04999f48bc242a0079 to your computer and use it in GitHub Desktop.
Save Deraen/cb04999f48bc242a0079 to your computer and use it in GitHub Desktop.
(defn mrg [[x & xrest :as X] [y & yrest :as Y] R]
(if (and X Y)
(if (<= x y)
(recur xrest Y (conj R x))
(recur X yrest (conj R y)))
(concat R X Y)))
(defn mrgsrt [X]
(if (> (count X) 1)
(let [[left right] (split-at (/ (count X) 2) X)]
(mrg (mrgsrt left) (mrgsrt right) []))
X))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment