SICP OpenCourse

SICP OpenCourse 2 : L1B Processe

2020-07-28  本文已影响0人  牛头酋长

SICP OpenCourse (Structure and Interpretation of Computer Programs)

1.THE PART OF THE ART OF DOING THIS SORT OF THING

    - How do I know what it is that I'm going to get on the film before I push the button.

    - Can I imagine in my mind the resulting image very precisely and clearly

    - SO, THE ART IS IMAGINE

        - See the future

        - Build INTERPRETER in mind ( COMMON PERSPECTIVE)

2. THE REAL WORKER IS ATOM, OUR BUSINESS IS ONLY BUILD ON TOP OF IT AND BORROW THE POWER FROM ATOM.

    - Actually the real power comes from meta-interpreter , which can be called GOD.

    - Meta-Interpreter alway working, so, atom can work base on it.

    - Atom working, so that, CPU can work base on it.

    - CPU working, so that, Program-Language interpreter can work base on it.

    - PL-interpreter working, so that, Program Language can work base on it.

    - PL working, so that, Application can work base on it.

    - From the Use's perspective Application working itself , but the real worker is only the Meta-Interpreter, that is GOD. The same as everything all around the world, for example human body.

3.THE SHAP OF PROCESS

- The FIRST way of  add whole numbers: ITERATION

(define (+ x y)
    (if (= x 0)
        y
        (+ (- 1 +x) (1 + y))))

(+ 3 4)
(+ 2 5)
(+ 1 6)
(+ 0 7)
7

time=O(x)
space=O(1)

- The SECOND way of  add whole numbers: RECURSION

(define (+ x y)
    (if (= x 0)
        y
        (1 + (+ (- 1 +x) y))))

(+ 3 4)
(1 + (+ 2 4))
(1 + (1 + (+ 1 4)))
(1 + (1 + (1 + (+ 0 4))))
(1 + (1 + (1 + 4)))
(1 + (1 + 5))
(1 + 6)
7

time=O(x)
space=O(x)

4.HIGHER-ORDER PROCEDURES : TWO LEVEL ABSTRACTION

(define ( sum term A next B)
    (if (> A B)
        0
        (+ (term A)
            (sum term
                (next A)
                next
                B))))

term and next are procedures too.

上一篇 下一篇

猜你喜欢

热点阅读