Extending the environment

Now, we need a procedure that follows the following contract:

;; CONTRACT
;; extend-env : env id val -> env

It should take an environment (a list), an id structure, and a value (implying a structure we have interpreted already), and return a new environment that has been extended with the symbol of the id associated with the value. I would recommend using a data structure called an env-pair to hold the symbol and value.

(define-struct env-pair (sym val))

This means your environment (a list) should just be a list of env-pairs.

Creative Commons License This work is licensed under a CC BY-SA 3.0 License.