[plt-scheme] Let, cond and local

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Mon Jan 5 17:31:22 EST 2004

On Monday, January 5, 2004, at 05:22 PM, Ricardo Massamitsu Nonomura 
wrote:

>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> Hi All,
>
> I'm getting a little confused, in the Revised5 Report on the 
> Algorithmic
> Language Scheme, on section 4.2.2 the constructs let, let* and letrec
> are described. But in the first line of my "homework" already in the
> first line I get the error msg:
>
> function call: expected a defined name or a primitive operation name
> after an open parenthesis, but found something else in: (m (cond (((<=
> 1800 j 1899) 23) ((<= 1900 j 2199) 24) (else (error "falsches 
> Jahr")))))


> Then consulting one of the resources listed by Ferguson and Jim
> (www.htdp.org) in the index of the book there is no mention of the let,
> let* and letrec, but I found something similar: local, which I cannot
> find any reference to it in the Revised5 Report, btw the construct cond
> uses "(" in the Revised5 Report while in the htdp.org it uses "[", does
> it matter??

No.

>
> Then:
> - Aren't the Revised5 Report and the htdp.org talking about the same
> Scheme?

No. Beginner is a subset of R5RS so that we can give good
error messages for minor syntactic mistakes.

> - Why did I get this error-msg using let?
> (I'm using DrScheme Beginning Student)

Because let, let* and friends are not a part of the Beginning
Student language. If you need those, move on to Intermediate Student.

> -----------
> I guess that the nested let* is wrong, but I cannot pass through the
> first...
>
> (define (oster j) (let* ((m (cond (((<= 1800 j 1899) 23)
>                                    ((<= 1900 j 2199) 24)
>                                    (else (error "falsches Jahr")))))
>                          (n (cond (((<= 1800 j 1899) 4)
>                                    ((<= 1900 j 2099) 5)
>                                    ((<= 2100 j 2199) 6))))
>                          (a (modulo j 19))
>                          (b (modulo j 4))
>                          (c (modulo j 7))
>                          (d (modulo (+ (* 19 a) m) 30))
>                          (e (modulo (+ (* 2 b) (* 4 c) (* 6 d) n) 7)))
>                     (let* (tag (if (> (+ d e) 9) (+ d e -9) (+ 22 d 
> e)))
>                       (monat (if (> (+ d e) 9) 'April 'Maerz))))
>   (if (= monat 'April) (cond ((= tag 26) (list 19 monat j))
>                              ((and (= tag 25) (= d 28) (= e 6) (> a 9))
> (list 18 monat j)) (list tag monat j))))
> ----------------
>

Frohe Ostern. -- Matthias

P.S. If you want to learn to program, go through HtDP doing just some
of the exercises (if you have experience otherwise). If not, read it.
You will see that the teaching languages make sense.



Posted on the users mailing list.