Re: Little LISPer and Ten Commandments

2010-10-01 Thread ax2groin
Yeah, it has been a good educational resource for working through.

I'm not finished, but I've put the Clojure version of all the code up
here:

https://www.assembla.com/code/little_clojure/subversion/nodes

Looking forward to those last couple chapters.

msd

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


Re: Little LISPer and Ten Commandments

2010-09-23 Thread Julian
I concur - that book is amazing.

Steve Yegge mentions he worked through the whole book in Scheme and
then Common LISP.
http://steve-yegge.blogspot.com/2006/06/shiny-and-new-emacs-22.html
(and he mentioned recently he was taking a look at Clojure.)

It looks like there is a blog or two online that work through it.
There also appear to be some guys on twitter talking about it.

My favourite bit is how you build the scheme evaluator at the end.

JG

On Sep 23, 6:10 am, David Sletten da...@bosatsu.net wrote:
 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/c9bd4e79e...

 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


Re: Little LISPer and Ten Commandments

2010-09-22 Thread David Sletten
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