my unsafe version works now, thanks to a LOT of help.

(defn msort [toSort]
 (with-local-vars [my-list (for [x toSort] [x])]
   (while (rest @my-list)
     (let [[l1 l2 & my-list-rest] @my-list]
       (var-set my-list (conj my-list-rest (listmerge l1 l2)))
       )) (first @my-list)))

now I'm trying to make a shorter version of the loop/recur version than
James provided because, even though I think I understand, somehow I probably
don't.  From what it looks like the my-list get's it's initial bindings from
the vector map operation, but after that, it gets them from recur.

Here's what I'm trying, but it says wrong number of arguments.  I haven't
taken the time yet to make the script environment.

(defn msort2 [toSort]
 (loop [[l1 l2 & my-list] (for [x toSort] [x])]
   (if (l2)
     (recur (conj my-list (listmerge l1 l2)))
     l1)))

i'm trying to say, "if there's a second list in my-list, then there's still
merging to do.

i tested that l1 l2 & stuff with edge cases, and it handles them fine (no
elements in list, one element, two, 3, etc).  I like that construct, a lot.
smart!

but my code doesn't work.


On Mon, Jan 12, 2009 at 10:59 PM, Timothy Pratley
<timothyprat...@gmail.com>wrote:

>
> > by the way, Tim, I've seen NB before as comments in J.  What's it stand
> for?
>
> An abbreviation for nota bene, a Latin expression meaning "note
> well".
>
>
> > I need to learn how to run closure code as a script then.
>
> http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started
> first section shows you how
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to