2014-07-09 5:11 GMT+02:00 Timothy Baldridge <tbaldri...@gmail.com>: > Prefer vectors over quoted lists '(1 2) vs [1 2]. There's rarely a case > (outside of macros) that you want the former. > > Instead of quoted lists of symbols: '(You cannot get that.) try strings > "You cannot get that" >
That is what Conrad uses. I would think that strings are much better also, but he says that there is a good reason to use a quoted list of symbols. And I have not finished the book yet. So maybe he is right. > Don't use defs inside defs. Instead move the defs to a global position and > then use binding or set-var-root! to set them. > I was not happy with it, but did not know better. At the moment I get binding and set-var-root! not working. > Better yet, use atoms to hold their contents, even better yet, pass the > game state into each function and have each function return a new game > state. > > Instead of: > > (defn walk [direction] > ... > (def ^:dynamic *location* (first edge)) > > Use atoms like this: > > (def location (atom nil)) > > (defn walk [direction] > ... > (reset! location (first edge)) > Yep, that would be better. I al-ready use atom in error-in-datastruct-p, so why not here? > Once you replace symbol lists with strings, you can easily do this instead > of syntax quoting: > > (str "There is a " (nth edge 2) " going " (nth edge 1) "from here") > As said: that was my idea also. I just finish the book to see if there is a real reason to use a quoted list. If not I replace it. > On Tue, Jul 8, 2014 at 6:24 PM, Bruce Wang <br...@brucewang.net> wrote: > >> Hi Cecil, >> >> You might want to check out this >> https://github.com/quux00/land-of-lisp-in-clojure >> >> Cheers, >> Bruce >> >> >> On Wed, Jul 9, 2014 at 9:49 AM, Cecil Westerhof <cldwester...@gmail.com> >> wrote: >> >>> I received the book land of lisp as a gift. I am trying to translate it >>> to Clojure. In chapter 5 there is a text game engine. In the attachment my >>> translation. What do you think of it? >>> >>> There are a few problems. >>> - The book displays all the lines of a look on separate lines. In my >>> case it is just one long line. Am I doing something wrong? >>> >>> - In Emacs Lisp you can use a function A in the definition of another >>> function B before you declared function A. Is it correct that this is not >>> possible in Clojure? >>> >>> - Al variables in land of lisp begin and end with an asterisk. As I >>> understood it, you only do this for variables that can be changed. So I >>> renamed some variables. Did I understand this correctly, or is the usage of >>> asterisks for something else? >>> >> -- Cecil Westerhof -- 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 Note that posts from new members are moderated - please be patient with your first post. 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.