On Sun, Jan 4, 2009 at 3:51 PM, Tom Ayerst <tom.aye...@gmail.com> wrote: > I tidied up a couple of things: > Changed function name 'verify-direction' to 'new-direction' (it is more than > a simple verification)
Sounds good. I made that change to mine. > Passed 'direction' and 'snake-head' to 'new-direction' to avoid accessing > global state from inside the function I also made a change to avoid that, but I just passed the dereferenced snake rather than the direction and head. > Used destructuring to simplify let statement in new-head (just to see what > it looked like) I guess I could do that even though I'm passing the whole snake struct, but going two levels deep in destructuring is probably confusing for readers. > Extracted dy,dx calculation in 'move-snake' into a 'delta' function That's nice! I'll do that too. > I notice everything seems to happen in the assignment vector in the 'let' in > move-snake? Is that good style? I'm not sure. I'm not either, but it seems pretty readable to me. > What would be interesting would be to have a second randomly moving snake to > avoid, that would force out some issues with global state etc. Yeah, that would be interesting. > The new code at the end: > ; Only run the application automatically if run as a script, > ; not if loaded in a REPL with load-file. > (println "*command-line-args* =" *command-line-args*) > (if *command-line-args* (main)) > Doesn't do what it says for me, it printlns and stops from clj, any idea > what I am doing wrong? I think it's related to details of your clj script. The relevant like in mine is this: java -cp $CP clojure.lang.Script $1 -- $* I can send you my whole clj script if you'd like. The latest version of my code that incorporates your changes is at http://www.ociweb.com/mark/programming/ClojureSnake.html. Thanks Tom! -- R. Mark Volkmann Object Computing, Inc. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---