Download presentation
Presentation is loading. Please wait.
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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.