norvig/paip-lisp

Errata for chapter 8

gregr opened this issue · 0 comments

gregr commented

I noticed a couple of mistakes in the definition of integrate (page 256) that probably slipped by testing. In the sketch below, I've indicated the mistakes with comments describing corrections:

(cond
  ((free-of exp x) `(* ,exp x))   ;; This should instead unquote x as in `(* ,exp ,x).
  ...
  ((starts-with exp '-)
   (ecase ...
     (1 (integrate (exp-lhs exp) x))  ;; This should instead build a unary minus operation to account for negation, as in `(- ,(integrate (exp-lhs exp) x)).
     ...