That book is amazing. Enjoy working through it, it will stretch your mind. However, keep in mind that their emphasis is on getting a feel for how recursion works. Real world Clojure code (any Lisp really) de-emphasizes recursion to some extent. Particularly with regard to list (sequence) processing (the name Lisp comes from "List processing" after all), Clojure has a powerful library of functions that handle much of what the book implements recursively. For example, if you would like to apply a function f to each element in a list you could write code similar to the book: (defn my-map [f l] (cond (empty? l) '() :else (cons (f (first l)) (my-map f (rest l)))) )
(my-map inc '(1 2 3 4 5)) => (2 3 4 5 6) Here we apply the "First Commandment"--is the list l empty? If so, return an empty list. Otherwise, apply the function to the first element of the list and recursively process the rest of the list. We could accomplish the same thing more succinctly in Clojure like this: (map inc '(1 2 3 4 5)) => (2 3 4 5 6) Clojure has a built-in 'map' function which iterates over each element in a sequence, not merely lists: (map dec [2 4 6 8]) => (1 3 5 7) (map #(Character/toUpperCase %) "Is this not pung?") => (\I \S \space \T \H \I \S \space \N \O \T \space \P \U \N \G \?) Furthermore, the book is pretty much using a dialect of Lisp called Scheme, and the semantics are a little different from Clojure. For instance, Clojure does not have the concept of 'atom'. It may actually be easier to work through the book in a Scheme environment (I used Common Lisp though). But what you learn there will help you later with Clojure. In fact, if you are brave here is some of the material from chapter 9 dealing with the Y-Combinator implemented in Clojure. It's pretty weird: http://groups.google.com/group/clojure/browse_thread/thread/c9bd4e79e5877a66 Have all good days, David Sletten On Sep 21, 2010, at 6:38 PM, ax2groin wrote: > Newbie here, to both LISP and Clojure. A friend has lent me a copy of > "The Little LISPer" and I've started working through it, using some > web resources to translate it into clojure. > > My questions: How relevant are the ten commandments? What modification > need to be made ... either to the commandments or to your code in > clojure? > > I ask because the first commandment (always ask null?) hasn't > translated directly into any single statement for me. I can achieve > the same with (or) to navigate the difference between nil and () in > clojure, but sure that difference is in there for a reason. > > Any other input on the other commandments or using the book in > general? > > Thanx > > -- > 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 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