280 likes | 442 Views
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)
E N D
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
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
GE <…> By Liat Snitovsky & Tal Achituv
GE <…> make-binary-operator Param: op, init1, init2 Body: (let…) (define (make-binary-operator op init1 init2) (let … … … ))) By Liat Snitovsky & Tal Achituv
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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