I am implementing merge sort in Clojure. Using my Java reference point, I need to create the equivalent of
for (int k = lo; k <= hi; k++) {
aux[k] = a[k];
}
in Clojure.
Here is what I have already tried:
(defn copy-vector [a aux] (doseq [k a] (swap! aux conj k)))
. But that seems horribly complicated for something that should be simple and is probably not even doing what I need it to it EXACTLY. Any inputs/guidance on the Clojure way of doing this?
Here are some mergesort implementations in Clojure.
[Spoiler warning: these are complete implementations. If you want to work through it yourself you might not want to look at these straight away.]
https://codereview.stackexchange.com/questions/23627/mergesort-implementation-in-clojure
https://gist.github.com/alco/2135276 (This second one includes links to several other implementations.)