[plt-scheme] why local? (just curious)

From: Sigrid Keydana (keydana at gmx.de)
Date: Thu Jan 15 12:12:04 EST 2009

Hi Shriram,

thanks for your patience :-) . In fact I'm not asking about sequential
assignment per se (I have been using let* for that), but in which
situation I would need this in combination with the mutual recursion
provided by letrec.

Now I've tried to think up an example myself in which both is present -
as I can't get at anything sensible, I just put some sequential
assignment in the beginning of the classic even-odd-letrec-example:

(define test
  (lambda (n)
    (letrec ((start-value n)
             (zero (- start-value start-value))
             (even? (lambda (n) (if (= n zero) #t (odd? (- n 1)))))
             (odd? (lambda (n) (if (= n zero) #f (even? (- n 1))))))
      (odd? n))))

(test 333)

The stupid example at least seems to show that with letrec, I get the
sequential assignment too... - or do I miss something here?


Shriram Krishnamurthi schrieb:
> Sorry -- I should have said "later BINDING", not later ASSIGNMENT.
> These are bindings, not assignments.
> S.

Posted on the users mailing list.