"SICP Exercise" 147 Exercise 4.3

Source: Internet
Author: User

Exercise 4-3 Original

Exercise 4.3. Rewrite Eval So, the dispatch is the do in data-directed style. Compare this with the datadirected differentiation procedure of exercise 2.73. (You may use the car of a compound expression as the type of the expression, as was appropriate for the syntax implemented In the This section.) .

Analysis

Refer to exercise 2.73.

 (define operation-table make-table)  (define get (operation-table ' Lookup-proc))  (define put (operation-table ' Insert-proc))  (put ' op ' quote text-of-quotation)  (put ' op ' set! eval-assignment)  (put ' op ' define eval-definition)  (put ' op ' if eval-if)  (put ' op ' lambda (Lambda (x y) ( make-procedure (lambda-parameters x) (lambda-body x) y )))  (put ' op ' begin (Lambda (x y) (eval-sequence (  Begin-sequence x  )))  (put ' op ' cond (Lambda (x y) ( evaln (  Cond->if x  )))  (Define (evaln expr env)          (Cond ((self-evaluating expr) expr)                    (variable expr ) (lookup-variable-value expr env))                    (get ' op (car expr)) (Applyn (get ' Op (car expr) expr ( env )))                    (application expr) (Applyn (evaln (operator expr) env ) (list-of-values (operands expr) env )))                    (else(error "unkown expression type--EVAL" expr))                      )) 

"SICP Exercise" 147 Exercise 4.3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.