letrec exercise 3.32 and 3.33

83 views
Skip to first unread message

tim_sw

unread,
Nov 24, 2008, 3:32:39 AM11/24/08
to EOPL3
Hello,

I've been trying to figure out how to add mutually recursive proc
definitions in letrec, extending it from the chapter 3 code downloaded
from the EPOL website.
My initial attempt was to add another type of expression to put inside
letrec, (which i called proc-defs)

(expression
("letrec"
proc-defs
"in" expression)
letrec-exp)

This triggered a cascade of changes all over the place, and it started
getting a little hacky, which felt wrong, so I was just wondering if I
am on the right path, and if anyone else has tried doing these
exercises before....
Thanks!
Tim

Simina Branzei

unread,
Nov 24, 2008, 3:50:58 PM11/24/08
to eo...@googlegroups.com
Hello Tim,

Yes I went through some of those exercises, and it does get quite hairy :-(. Also the debugging mechanism wasn't that good.  But  maybe it's just me not having enough experience with Scheme.

Simina

2008/11/24 tim_sw <tim_s...@yahoo.com>

Dwayne Crooks

unread,
Apr 6, 2020, 10:53:01 AM4/6/20
to EOPL3
For me it helped when I worked out the syntax and then the semantics
of mutually recursive letrec. Doing that provides a nice guide that helps
you to figure out the implementation. Furthermore, if you have trouble
figuring out the semantics then you should step through the semantics
of the program and reason out what needs to happen at each step.

i.e.

(value-of <<letrec even(x) ... odd(x) ... in (odd 13)>> p)
= (value-of <<(odd 13)>> ?)

How should the environment be extended so that it all works out. That's
the key thing you need to figure out. Play with some ideas and see how
you can continue the computation.

Hope that helps.
Reply all
Reply to author
Forward
0 new messages