I'm not planning on programming like this, but just to try to finish this up . . . .it's still not working. I get an odd error when I actually try to sort something that iSeq doesn't work on integers. I have no idea where to still the (first my-list) at the end so it returns, too. No need to reply, per se. Just reporting on how far I got tonight. I'm sure someone answered this already and I haven't read through it all enough.
(defn listmerge [l1 l2] (let [l1first (first l1) l2first (first l2)] (cond (empty? l1) l2 (empty? l2) l1 (< l1first l2first) (cons l1first (listmerge (rest l1) l2)) :else (cons l2first (listmerge (rest l2) l1)))))) (defn msort [toSort] (with-local-vars [my-list (for [x toSort] [x])] (while (rest (var-get my-list)) (let [[l1 l2 & my-list2] (var-get my-list)] (var-set my-list (concat my-list2 (listmerge l1 l2)))) (first my-list)))) ;; test it out (msort [4 53 54 3 5 7 8]) On Mon, Jan 12, 2009 at 1:29 AM, e <evier...@gmail.com> wrote: > looks like an awesome book. will check it out more. thanks. > > > On Mon, Jan 12, 2009 at 1:06 AM, Josip Gracin <josip.gra...@gmail.com>wrote: > >> >> On Sun, Jan 11, 2009 at 10:33 PM, e <evier...@gmail.com> wrote: >> > thanks for your patience. I think I'm starting to get it. >> > Interesting discussion on tail recursion. >> >> Just to add $0.02... The fact that 'recur' in Clojure is actually used >> to implement iterative and not recursive processes is easier to >> understand after reading SICP (chapter 1, >> http://mitpress.mit.edu/sicp/full-text/book/book.html). >> >> >> >> > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---