L11Clos - Closures and Streams cs784(Prasad) L11Clos 1...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
cs784(Prasad) L11Clos 1 Closures and Streams
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
cs784(Prasad) L11Clos 2 Models of Evaluation Substitution-based (define (square  x ) (*  x x )) ((lambda ( x   y     (+ (square  x ) (square  y )))                            (- 5 3)   5 ) = (+ (square 2) (square 5))  = (+ (* 2 2) (* 5 5)) =   (+     4      25) =          29 
Background image of page 2
cs784(Prasad) L11Clos 3 Expression Evaluation Options To evaluate: (operator operand1 operand2 operand3 . ..) Applicative-Order Evaluation ( call by value) evaluate each of the sub-expressions. apply the leftmost result to the rest. Normal-Order Evaluation ( call by name ) apply the leftmost (lambda) sub-expression to the rest and expand. (Argument sub- expressions get evaluated when necessary.)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
cs784(Prasad) L11Clos 4 Models of Evaluation Environment-based ((lambda ( x   y     (+ (square x) (square y)))                            (- 5 3)   5 ) = (+  (square x)   (square y) )    x = 2 , y = 5 = (+  (*  x x )                    x = 2 , y = 5          (*  x x x x )  )                 x x = 5 , y = 5 = (+     4      25) =          29 
Background image of page 4
cs784(Prasad) L11Clos 5 An extended example (define square (lambda (x) (* x x))) (define sum-of-squares      (lambda (x y)            (+ (square x) (square y)))) (define f (lambda (a)     (sum-of-squares (+ a 1) (* a 2))))
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
cs784(Prasad) L11Clos 6 Initial Global Environment
Background image of page 6
cs784(Prasad) L11Clos 7 Executing (f 5)   and   sum-of-squares
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
cs784(Prasad) L11Clos
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/02/2011 for the course CS cs784 taught by Professor Tkprasad during the Spring '11 term at New York Institute of Technology-Westbury.

Page1 / 27

L11Clos - Closures and Streams cs784(Prasad) L11Clos 1...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online