6. Defining new procedures 3(define (lambda? e)(tag-check e 'lambda*)) 5 (define (eval exp env. (cond 789 ((number? exp exp (lookup exp env)) ((define? exp) (eval-define exp env)) ((if? exp) (eval-if exp env)) ((lambda? ex (eval-lambda exp env)) ((application? exp)(apply (eval (car exp) env) (map (lambda (e)(eval e env (cdr exp)))) (else 456789012 (error unknown expression exp))) (define (eval-lambda exp env) (let ((args (cadr exp)) (body (caddr exp))) (make-compound args body env))) 23 (define (apply operator operands) 24 (cond ((primitive? operator (scheme-apply (get-scheme -procedure operator 26 ((compound? operator) eval (body operator) (extend-env-with-new-frame 30 (parameters operator) 31 operands (env operator)))) (else (error operator not a procedure:operator)))) 36 38 ADt that implements the "double bubble" 40 (define compound-tag 'compound) 41 (define (make-compound parameters body en 42 (list compound-tag parameters body env) 43(define (compound? exp) (tag-check exp compound-tag)) 45 (define (parameters compound) (cadr compound) 46 (define (body compound) (cadd compound)) define (env compound) (cadddr compound))1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 6. Defining new procedures (define (lambda? e) (tag-check e 'lambda*)) (define (eval exp env) (cond ((number? exp) exp) ((symbol? exp) (lookup exp env)) ((define? exp) (eval-define exp env)) ((if? exp) (eval-if exp env)) ((lambda? exp) (eval-lambda exp env)) ((application? exp) (apply (eval (car exp) env) (map (lambda (e) (eval e env)) (cdr exp)))) (else (error "unknown expression " exp)))) (define (eval-lambda exp env) (let ((args (cadr exp)) (body (caddr exp))) (make-compound args body env))) (define (apply operator operands) (cond ((primitive? operator) (scheme-apply (get-scheme-procedure operator) operands)) ((compound? operator) (eval (body operator) (extend-env-with-new-frame (parameters operator) operands (env operator)))) (else (error "operator not a procedure: " operator)))) ;; ADT that implements the “double bubble” (define compound-tag 'compound) (define (make-compound parameters body env) (list compound-tag parameters body env)) (define (compound? exp) (tag-check exp compound-tag)) (define (parameters compound) (cadr compound)) (define (body compound) (caddr compound)) (define (env compound) (cadddr compound))