> (run '(define ev (lambda (n) (letrec ((even (lambda (n) (if (zero n) 1 (odd (sub1 n))))) (odd (lambda (n) (if (zero n) 0 (even (sub1 n)))))) (even n))))) > (run '(ev 10)) 1 > (run '(ev 9)) 0
(dynlet ((var exp) ...) body)
that dynamically binds its variables, which belong to a separate
dynvar namespace. Also provide a dynamic variable
reference form, with syntax (dyn var). Hint: Use two environments
Some further description of dynlet (with examples) is available.
Note that if every procedure is of the form
(lambda (v ...) (dynlet ((v v) ...) body))
and only dyn variable references are used in the
body, then one gets the semantics of the dynamic binding
interpreter in the book.
Write your answers to the exercises in a file (with comments, following the proper indentation rules), and send that file to
c311@lakshmi.cs.indiana.eduwith the subject line
6Assuming you've saved your homework in the file ``asgn.ss'' in the current directory, one way to submit is with the command:
Mail -s "6" c311@lakshmi.cs.indiana.edu < asgn.ssIf you use the
define-record stuff, include the expression
(load "record.ss")in your submission.
Back to the c311 page
ehilsdal@cs.indiana.edu