Hand Evals in DrRacket Hand evaluation helps you learn how Racket reduces programs to values
Example 1 (+ (* 2 3) 6) (+ 6 6) 12
Example 2 (define (foo x) (+ x 3)) (* (foo 5) 4) (* (+ 5 3) 4) (* 8 4) 32
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)) ( (foo -1)) [see next slide]
Example 3 (cont) (define (foo x) (+ x 3)) ( (foo -1)) ( (+ -1 3)) ( ) 22
Example 4 (cond [(= 5 0) ‘never] [else (* 6 2)]) (* 6 2) 12
Summary: How to Hand Eval 1.Find the innermost expression 2.Evaluate one step 3.Repeat until all have a value