There is a confusing sentence beneath the first example on this page. The sentence reads "Instead of responding with the sum of the numbers 1 and 2, ...". Instead, it should instead read "Instead of responding with two to the third power, ...".
(Found by Jeff Gonis)
When we check the value of *arch-enemy* at the end it should be USELESS-OLD-JOHNNY instead of just JOHNNY:
> *arch-enemy* USELESS-OLD-JOHNNY
(Found by "speck" on HN News)
The second example line contains an error: The cons command always requires two parameters- If the second slot in the cell should be the empty list we need to explicitly put an empty list () in that slot:
;;Identical lists created in different ways still compare as the same > (equal '(1 2 3) (cons 1 (cons 2 (cons 3 ())))) T
(Found by Paul King)
The function tweak-text has two glitches in it, though it will run OK on most Lisp implementations. First of all, it uses the eq function to compare characters- Characters should always be checked with other functions such as eql or char-equal as per the ANSI spec. Also, there's an unnecessary check of (or caps lit) that can be simplified to caps. Below is the improved version of this function:
(defun tweak-text (lst caps lit) (when lst (let ((item (car lst)) (rest (cdr lst))) (cond ((eql item #\space) (cons item (tweak-text rest caps lit))) ((member item '(#\! #\? #\.)) (cons item (tweak-text rest t lit))) ((eql item #\") (tweak-text rest caps (not lit))) (lit (cons item (tweak-text rest nil lit))) (caps (cons (char-upcase item) (tweak-text rest nil lit))) (t (cons (char-downcase item) (tweak-text rest nil nil)))))))
(Found by Simon Friedberger and _3b in #lisp on freenode)
It states in the note that foo? and foo* will get converted to foo by the dot-name function. It should instead say they get converted to foo_.
(Found by Paul S. Wilson)
The loop in the board-attack function uses a non-standard looping construct that works fine in CLISP but is not supported by all CL implementations. Below is a standard-compliant version, which simply adds the phrase "from 0" to the loop:
(defun board-attack (board player src dst dice) (board-array (loop for pos from 0 for hex across board collect (cond ((eq pos src) (list player 1)) ((eq pos dst) (list player (1- dice))) (t hex)))))
(Found by Peter Frings)
The announce-winner function is dirty, but it has the "clean" icon in the left margin. Instead, it should have the "dirty" icon.
(Found by "Brisance" on the Land of Lisp forum)
The my-length example function contains a bug- It should reference self and not f. Below is the correct version of this function:
(defun my-length (lst) (recurse (lst lst acc 0) (split lst (self tail (1+ acc)) acc)))
(Found by Peter Frings)
Since the first item in the inventory list is not a true inventory item, the have command should skip this item. It is a completely harmless bug, but here is a better way to write this function:
(defun have (object) (member object (cdr (inventory))))
(Found by Francois-Rene Rideau)
According to the Common Lisp specification, you should not declare a variable with the setf command. Instead you should use defparameter or defvar. However, most CL implementations will let you get away with this. On these pages I accidentally used (setf *bucket-filled* nil) to initialize this variable. I should have, instead, written (defparameter *bucket-filled* nil).
(Found by Christian Mueller and Peter Frings)
In chapter 19 it asks you to load the file "svg.lisp" we created in chapter 17. Unfortunately, the version of the macro that is expected in chapter 19 allows you to pass in the width & height of the picture, which the SVG macro in chapter 17 did not. After loading the svg.lisp chapter in chapter 19, redefine the svg macro as follows:
(defmacro svg (width height &body body) `(tag svg (xmlns "http://www.w3.org/2000/svg" "xmlns:xlink" "http://www.w3.org/1999/xlink" height ,height width ,width) ,@body))
Then all the code in chapter 19+ should work correctly. The downloadable source on my website for chapter 19 has been corrected to reflect this.
(Found by Paul Horsfall)