hw11 - ; Exercise 4.3 (define eval-table...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
;; Exercise 4.3 (define eval-table (make-eq-hash-table)) (define get (lambda (key) (hash-table/get eval-table key #f))) (define put (lambda (key proc) (hash-table/put! eval-table key proc))) (define (eval exp env) (cond ((self-evaluating? exp) exp) ((variable? exp) (lookup-variable-value exp env)) ((get (car exp)) ((get (car exp)) exp env)) ((application? exp) (apply (eval (operator exp) env) (list-of-values (operands exp) env))) (else (error "Unknown expression type -- EVAL" exp)))) (put 'quote (lambda (exp env) (text-of-quotation exp))) (put 'set! (lambda (exp env) (eval-assignment exp env))) (put 'define eval-definition) (put 'if eval-if) (put 'lambda (lambda (exp env) (make-procedure (lambda-parameters exp) (lambda-body exp) env))) (put 'begin (lambda (exp env) (eval-sequence (begin-actions exp) env))) (put 'cond (lambda (exp env) (eval (cond->if exp) env))) ;; Exercise 4.6 (define (eval exp env) ; . ..... ((let? exp) (eval (let->combination exp) env))
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/30/2010 for the course EECS 21281 taught by Professor Harvey during the Spring '10 term at Berkeley.

Page1 / 2

hw11 - ; Exercise 4.3 (define eval-table...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online