[racket] PLAI Section 1.3, Page 8

From: Eric Tanter (etanter at dcc.uchile.cl)
Date: Tue Jan 18 09:30:37 EST 2011

Hi Kevin,

PLAI is definitely written for self-study, but you shouldn't skip intermediate sections ;)
In your case, you're missing the define-type for AE (section 1.2, page 6). define-type generates the constructors you're after.

-- Éric


On Jan 18, 2011, at 11:17 AM, Kevin Taylor wrote:

> All,
> 
> I am working through PLAI for self-study. I've gotten to section 1.3, page 8. There is an example of parsing code and some example output. Unfortunately, clearly num, add, and sub need to be defined for the example code to run.
> 
> ;; parse : sexp −→ AE ;; to convert s-expressions into AEs
> (define (parse sexp)
> (cond
> [(number? sexp) (num sexp)] 
> [(list? sexp)
> (case (first sexp) 
> [(+) (add (parse (second sexp))
> (parse (third sexp)))] 
> [(-) (sub (parse (second sexp))
> (parse (third sexp)))])]))
> 
> Since it isn't mentioned in the book at all that num, add, and sub need to be defined in order to run the example code, I am getting the impression that this book was not intended for self-study. (Explaining that num, add, and sub need to be defined and giving some hints as to how is something that an instructor would likely cover.) Any thoughts on that before I get further into the book?
> 
> Also, are there any pointers that someone on the list can provide for this? Either conceptual guidance or pointers to somewhere on the web where I can do some prerequisite reading in order to get this parsing code working?
> 
> I don't want to proceed until I have this example code running.
> 
> Cheers and TIA, 
> 
> --
> Kevin
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users



Posted on the users mailing list.