1 / 28

SCHEME Environment Model

SCHEME Environment Model. The Function: (define (make-binary-operator op init1 init2) (let ((output (op init1 init2))) (lambda (m) (cond ((eq? m 'input1) (lambda (v) (set! init1 v) (set! output (op init1 init2)) output)) ((eq? m 'input2)

august
Download Presentation

SCHEME Environment Model

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SCHEME Environment Model The Function: (define (make-binary-operator op init1 init2) (let ((output (op init1 init2))) (lambda (m) (cond ((eq? m 'input1) (lambda (v) (set! init1 v) (set! output (op init1 init2)) output)) ((eq? m 'input2) (lambda (v) (set! init2 v) (set! output (op init1 init2)) output)) ((eq? m 'output) output) (else (error "Unknown request" m)))))) By Liat Snitovsky & Tal Achituv

  2. SCHEME Environment Model The Interpreter Commands: >(define p1 (make-binary-operator + 0 0)) >((p1 'input1) 3) >((p1 'input2) 5) >(p1 'output) By Liat Snitovsky & Tal Achituv

  3. GE <…> By Liat Snitovsky & Tal Achituv

  4. GE <…> make-binary-operator Param: op, init1, init2 Body: (let…) (define (make-binary-operator op init1 init2) (let … … … ))) By Liat Snitovsky & Tal Achituv

  5. + GE <…> make-binary-operator E1 Op: Init1: 0 Init2: 0 Param: op, init1, init2 Body: (let…) (define p1 (make-binary-operator + 0 0)) By Liat Snitovsky & Tal Achituv

  6. + GE <…> make-binary-operator E1 Op: Init1: 0 Init2: 0 Param: op, init1, init2 Body: (let…) Param: output Body: ((m)…) (define p1 (make-binary-operator + 0 0)) By Liat Snitovsky & Tal Achituv

  7. + GE <…> make-binary-operator E1 E2 Op: Init1: 0 Init2: 0 Output: 0 Param: op, init1, init2 Body: (let…) Param: output Body: ((m)…) (define p1 (make-binary-operator + 0 0)) By Liat Snitovsky & Tal Achituv

  8. + GE <…> make-binary-operator E1 E2 Op: Init1: 0 Init2: 0 Output: 0 Param: op, init1, init2 Body: (let…) Param: output Body: ((m)…) Param: m Body: (cond…) (define p1 (make-binary-operator + 0 0)) By Liat Snitovsky & Tal Achituv

  9. + GE <…> make-binary-operator P1 E1 E2 Op: Init1: 0 Init2: 0 Output: 0 Param: op, init1, init2 Body: (let…) Param: output Body: ((m)…) Param: m Body: (cond…) (define p1 (make-binary-operator + 0 0)) By Liat Snitovsky & Tal Achituv

  10. + GE <…> make-binary-operator P1 E1 E2 E3 Op: Init1: 0 Init2: 0 Output: 0 m: input1 Param: op, init1, init2 Body: (let…) Param: output Body: ((m)…) Param: m Body: (cond…) ((p1 'input1) 3) By Liat Snitovsky & Tal Achituv

  11. + GE <…> make-binary-operator P1 E1 E2 E3 Op: Init1: 0 Init2: 0 Output: 0 m: input1 Param: op, init1, init2 Body: (let…) Param: output Body: ((m)…) Param: m Body: (cond…) Param: v Body: (set!…) …) ((p1 'input1) 3) By Liat Snitovsky & Tal Achituv

  12. + GE <…> make-binary-operator P1 E1 E2 E3 E4 Op: Init1: 0 Init2: 0 Output: 0 m: input1 v: 3 Param: op, init1, init2 Body: (let…) Param: output Body: ((m)…) Param: m Body: (cond…) Param: v Body: (set!…) …) ((p1 'input1) 3) [mbo->(lambda (v)…] By Liat Snitovsky & Tal Achituv

  13. + GE <…> make-binary-operator P1 E1 E2 E3 E4 Op: Init1: 0 Init2: 0 Output: 0 m: input1 v: 3 Param: op, init1, init2 Body: (let…) Param: output Body: ((m)…) Param: m Body: (cond…) Param: v Body: (set!…) …) ((p1 'input1) 3) [mbo->(lambda (v)…] By Liat Snitovsky & Tal Achituv

  14. + GE <…> make-binary-operator P1 E1 E2 E3 E4 Op: Init1: 0 Init2: 0 Output: 0 m: input1 v: 3 Param: op, init1, init2 Body: (let…) Param: output Body: ((m)…) Param: m Body: (cond…) Param: v Body: (set!…) …) ((p1 'input1) 3) [mbo->(lambda (v)…->(set! init1 v)] By Liat Snitovsky & Tal Achituv

  15. + GE <…> make-binary-operator P1 E1 E2 E3 E4 Op: Init1: 0 3 Init2: 0 Output: 0 m: input1 v: 3 Param: op, init1, init2 Body: (let…) Param: output Body: ((m)…) Param: m Body: (cond…) Param: v Body: (set!…) …) ((p1 'input1) 3) [mbo->(lambda (v)…->(set! init1 v)] By Liat Snitovsky & Tal Achituv

  16. + GE <…> make-binary-operator P1 E1 E2 E3 E4 Op: Init1: 0 3 Init2: 0 Output: 0 m: input1 v: 3 Param: op, init1, init2 Body: (let…) Param: output Body: ((m)…) Param: m Body: (cond…) Param: v Body: (set!…) …) ((p1 'input1) 3) [mbo->(lambda (v)…->(set! output …] By Liat Snitovsky & Tal Achituv

  17. + GE <…> make-binary-operator P1 E1 E2 E3 E4 Op: Init1: 0 3 Init2: 0 Output: 0 3 m: input1 v: 3 Param: op, init1, init2 Body: (let…) Param: output Body: ((m)…) Param: m Body: (cond…) Param: v Body: (set!…) …) ((p1 'input1) 3) ;value: 3 By Liat Snitovsky & Tal Achituv

  18. + GE <…> make-binary-operator P1 E1 E2 E3 E4 Op: Init1: 0 3 Init2: 0 Output: 0 3 m: input1 v: 3 Param: op, init1, init2 Body: (let…) Param: output Body: ((m)…) Param: m Body: (cond…) Param: v Body: (set!…) …) E5 m: input2 ((p1 'input2) 5) … By Liat Snitovsky & Tal Achituv

  19. + GE <…> make-binary-operator P1 E1 E2 E3 E4 Op: Init1: 0 3 Init2: 0 Output: 0 3 m: input1 v: 3 Param: op, init1, init2 Body: (let…) Param: output Body: ((m)…) Param: m Body: (cond…) Param: v Body: (set!…) …) E5 m: input2 ((p1 'input2) 5) … Param: v Body: (set!…) …) By Liat Snitovsky & Tal Achituv

  20. + GE <…> make-binary-operator P1 E1 E2 E3 E4 Op: Init1: 0 3 Init2: 0 Output: 0 3 m: input1 v: 3 Param: op, init1, init2 Body: (let…) Param: output Body: ((m)…) Param: m Body: (cond…) Param: v Body: (set!…) …) E5 E6 m: input2 v: 5 ((p1 'input2) 5) … Param: v Body: (set!…) …) By Liat Snitovsky & Tal Achituv

  21. + GE <…> make-binary-operator P1 E1 E2 E3 E4 Op: Init1: 0 3 Init2: 0 Output: 0 3 m: input1 v: 3 Param: op, init1, init2 Body: (let…) Param: output Body: ((m)…) Param: m Body: (cond…) Param: v Body: (set!…) …) E5 E6 m: input2 v: 5 ((p1 'input2) 5) … Param: v Body: (set!…) …) By Liat Snitovsky & Tal Achituv

  22. + GE <…> make-binary-operator P1 E1 E2 E3 E4 Op: Init1: 0 3 Init2: 0 Output: 0 3 m: input1 v: 3 Param: op, init1, init2 Body: (let…) Param: output Body: ((m)…) Param: m Body: (cond…) Param: v Body: (set!…) …) E5 E6 m: input2 v: 5 ((p1 'input2) 5) … Param: v Body: (set!…) …) By Liat Snitovsky & Tal Achituv

  23. + GE <…> make-binary-operator P1 E1 E2 E3 E4 Op: Init1: 0 3 Init2: 0 5 Output: 0 3 m: input1 v: 3 Param: op, init1, init2 Body: (let…) Param: output Body: ((m)…) Param: m Body: (cond…) Param: v Body: (set!…) …) E5 E6 m: input2 v: 5 ((p1 'input2) 5) … Param: v Body: (set!…) …) By Liat Snitovsky & Tal Achituv

  24. + GE <…> make-binary-operator P1 E1 E2 E3 E4 Op: Init1: 0 3 Init2: 0 5 Output: 0 3 m: input1 v: 3 Param: op, init1, init2 Body: (let…) Param: output Body: ((m)…) Param: m Body: (cond…) Param: v Body: (set!…) …) E5 E6 m: input2 v: 5 ((p1 'input2) 5) … Param: v Body: (set!…) …) By Liat Snitovsky & Tal Achituv

  25. + GE <…> make-binary-operator P1 E1 E2 E3 E4 Op: Init1: 0 3 Init2: 0 5 Output: 0 3 8 m: input1 v: 3 Param: op, init1, init2 Body: (let…) Param: output Body: ((m)…) Param: m Body: (cond…) Param: v Body: (set!…) …) E5 E6 m: input2 v: 5 ((p1 'input2) 5) ;value: 8 Param: v Body: (set!…) …) By Liat Snitovsky & Tal Achituv

  26. + GE <…> make-binary-operator P1 E1 E2 E3 E4 Op: Init1: 0 3 Init2: 0 5 Output: 0 3 8 m: input1 v: 3 Param: op, init1, init2 Body: (let…) Param: output Body: ((m)…) Param: m Body: (cond…) Param: v Body: (set!…) …) E5 E6 m: input2 v: 5 E7 m: output (p1 'output) Param: m Body: (cond…) Param: v Body: (set!…) …) By Liat Snitovsky & Tal Achituv

  27. + GE <…> make-binary-operator P1 E1 E2 E3 E4 Op: Init1: 0 3 Init2: 0 5 Output: 0 3 8 m: input1 v: 3 Param: op, init1, init2 Body: (let…) Param: output Body: ((m)…) Param: m Body: (cond…) Param: v Body: (set!…) …) E5 E6 m: input2 v: 5 E7 m: output (p1 'output) Param: m Body: (cond…) Param: v Body: (set!…) …) By Liat Snitovsky & Tal Achituv

  28. + GE <…> make-binary-operator P1 E1 E2 E3 E4 Op: Init1: 0 3 Init2: 0 5 Output: 0 3 8 m: input1 v: 3 Param: op, init1, init2 Body: (let…) Param: output Body: ((m)…) Param: m Body: (cond…) Param: v Body: (set!…) …) E5 E6 m: input2 v: 5 E7 m: output (p1 'output) ;value: 8 Param: m Body: (cond…) Param: v Body: (set!…) …) By Liat Snitovsky & Tal Achituv

More Related