Comma's? Possible errata pg 72

165 views
Skip to first unread message

richard kappler

unread,
Jul 20, 2012, 5:02:17 PM7/20/12
to land-o...@googlegroups.com
Greetings all, new to the list and new to Lisp.  I purchased Land of Lisp, Kindle edition and am working my way through it but have hit a wall.  In Ch 5, Building a text game engine, in the function describe-path my copy shows

(defun describe-path (edge)  '(there is a ,(caddr edge) going ,(cadr edge) from here.))

While typing it in I got

Error while reading: A comma appears outside the scope of a backquote (or there are too many commas).
Error while reading: A comma appears outside the scope of a backquote (or there are too many commas).
Error while reading: A comma appears outside the scope of a backquote (or there are too many commas).

hmmm

I decided to see what would happen anyway.

(describe-path '(garden west door))

gave no return.

I thought to myself, maybe whoever converted the book to Kindle format botched it (not that such a thing would EVER happen) so I ditched the commas and replaced them with a single quote, thinking that shouldn't be right, but I am, after all, learning.

CL-USER 75 : 8 > (describe-path '(garden west door))
(THERE IS A (QUOTE (CADDR EDGE)) GOING (QUOTE (CADR EDGE)) FROM HERE.)

So I ditched the single quotes and tried it again, thinking, "Now I'm lost"

CL-USER 77 : 8 > (describe-path '(garden west door))
(THERE IS A (CADDR EDGE) GOING (CADR EDGE) FROM HERE.)

I checked the errata page, didn't see anything, searched the archives of this list, didn't find anything.  What am I missing?

regards, Richard

richard kappler

unread,
Jul 20, 2012, 5:12:12 PM7/20/12
to land-o...@googlegroups.com
Nevermind, found it.  It's supposed to be a backquote.

EXCELLENT book by the way.  I'm really enjoying it.  Working Land of Lisp at the same time as Norvig's Paradigms of Artificial Intelligence - Case studies in Common Lisp and Winston & Horns' Lisp, 3rd Edition.  Loving Lisp!

regards, Richard
--
"Treat all disasters as if they were trivialities but never treat a triviality as if it were a disaster." 
       -- Quentin Crisp

Purity Control

unread,
Jul 20, 2012, 5:12:30 PM7/20/12
to land-o...@googlegroups.com
Where you have typed:

(defun describe-path (edge)  '(there is a ,(caddr edge) going ,(cadr edge) from here.))

the apostrophe should be a backtick
ie:

(defun describe-path (edge)  `(there is a ,(caddr edge) going ,(cadr edge) from here.))


the backtick basically says take anything that starts with a comma and return the value of the lisp expression. I am not sure of your background but a rather poor analogy might be embedded php commands in html of a php script.

ie <h1> <?php print(hello); ?> </h1>

richard kappler

unread,
Jul 20, 2012, 5:22:36 PM7/20/12
to land-o...@googlegroups.com
Well, I THOUGHT I had it.  Thanks for the reply Purity Control.   So, I've always understood the backtick to be the reversed quote under the tilde, no?  When I typed it out though, mine look just as I described, a reversed quote, whereas yours posted in your reply looks like a reversed comma.  Using my backtick key did not solve the problem:

CL-USER 78 : 8 > (defun describe-path (edge) '(there is a `(caddr edge) going `(cadr edge) from here.))
DESCRIBE-PATH

CL-USER 79 : 8 > (describe-path '(garden west door))
(THERE IS A (QUOTE (CADDR EDGE)) GOING (QUOTE (CADR EDGE)) FROM HERE.)

Am I using the wrong key?  Maybe it's the keyboard mapping?  If it helps, I'm using Lispworks in Ubuntu Precise on a 64 bit HP G62.

confounded, Richard

richard kappler

unread,
Jul 20, 2012, 5:27:54 PM7/20/12
to land-o...@googlegroups.com
Wait, scratch that.  I'm an idiot.  Thanks for the help.
Reply all
Reply to author
Forward
0 new messages