Posts

Showing posts from October, 2019

SICP Exercise 4.11 frame as list of bindings

Exercise 4.11.   Instead of representing a frame as a pair of lists, we can represent a frame as a list of bindings, where each binding is a name-value pair. Rewrite the environment operations to use this alternative representation. SOLUTION The code and tests are here .

SICP Exercise 4.10 new syntax for Scheme

Exercise 4.10.    By using data abstraction, we were able to write an  eval  procedure that is independent of the particular syntax of the language to be evaluated. To illustrate this, design and implement a new syntax for Scheme by modifying the procedures in this section, without changing  eval  or  apply . SOLUTION Here are the syntax changes I made: Comparison expressions of like (< x y) changed to a more intuitive (x < y). This  applies to the following operators: <, >, <=, >= and ==. Note that for equality I have  introduced the operator "==". This is because I want to reserve "=" for assignments  and definitions Assignment syntax changed from (set! x value) to (x = value) 'if' syntax changed (see "if" section below) The code and tests are here .