Presentation is loading. Please wait.

Presentation is loading. Please wait.

Hand Evals in DrRacket Hand evaluation helps you learn how Racket reduces programs to values.

Similar presentations


Presentation on theme: "Hand Evals in DrRacket Hand evaluation helps you learn how Racket reduces programs to values."— Presentation transcript:

1 Hand Evals in DrRacket Hand evaluation helps you learn how Racket reduces programs to values

2 Example 1 (+ (* 2 3) 6) (+ 6 6) 12

3 Example 2 (define (foo x) (+ x 3)) (* (foo 5) 4) (* (+ 5 3) 4) (* 8 4) 32

4 Example 3 (define (foo x) (+ x 3)) (+ (foo 5) (foo 9) (foo -1)) (+ (+ 5 3) (foo 9) (foo -1)) (+ 8 (foo 9) (foo -1)) (+ 8 (+ 9 3) (foo -1)) (+ 8 12 (foo -1)) [see next slide]

5 Example 3 (cont) (define (foo x) (+ x 3)) (+ 8 12 (foo -1)) (+ 8 12 (+ -1 3)) (+ 8 12 2) 22

6 Example 4 (cond [(= 5 0) ‘never] [else (* 6 2)]) (* 6 2) 12

7 Summary: How to Hand Eval 1.Find the innermost expression 2.Evaluate one step 3.Repeat until all have a value


Download ppt "Hand Evals in DrRacket Hand evaluation helps you learn how Racket reduces programs to values."

Similar presentations


Ads by Google