• Racket HW Guide

# Pages … Course Offerings 2020-Fall Racket HW Guide Page History

## Key

• This line was removed.
• Formatting was changed.

...

• Note that you can create your entire homework file including solutiob ns solutions to expository problems using the DrRacket editor.

...

• Most expository problems will be hand-evaluation problems where you are asked to evaluate a particular Racket program invocation. You must format your hand evaluation exactly like our examples (except you will need to insert a comment escape character :if the evaluation is embedded in a Racket file with executable Racket code.
• Example 1: Hand evaluation

Code Block
```        Given
(define poly (lambda (x y) (+ (expt 2 x) y)))
(poly 3 5)
=> ((lambda (x y) (+ (expt 2 x) y)) 3 5)
=> (+ (expt 2 3) 5))
=> (+ 8 5)
=> 13
```
• Example 2: Hand evaluation

Code Block
```        Given
(define fact (lambda (n) (if (zero? n) 1 (* n (fact (- n 1))))))
(fact 4)
=> (if (zero? 4) 1 (* 4 (fact (- 4 1))))
=> (if false 1 (* 4 (fact (- 4 1))))
=> (* 4 (fact (- 4 1)))
=> (* 4 (fact 3))
=> (* 4 (if (zero? 3) 1 (* 3 (fact (- 3 1)))))
=> (* 4 (if false 1 (* 3 (fact (- 3 1)))))
=> (* 4 (* 3 (fact (- 3 1))))
=> (* 4 (* 3 (fact 2)))
=> (* 4 (* 3 (if (zero? 2) 1 (* 2 (fact (- 2 1))))))
=> (* 4 (* 3 (if false 1 (* 2 (fact (- 2 1))))))
=> (* 4 (* 3 (* 2 (fact (- 2 1)))))
=> (* 4 (* 3 (* 2 (fact 1))))
=> (* 4 (* 3 (* 2 (if (zero? 1) 1 (* 1 (fact (- 1 1)))))))
=> (* 4 (* 3 (* 2 (if false 1 (* 1 (fact (- 1 1)))))))
=> (* 4 (* 3 (* 2 (* 1 (fact (- 1 1))))))
=> (* 4 (* 3 (* 2 (* 1 (fact 0)))))
=> (* 4 (* 3 (* 2 (* 1 (if (zero? 0) 1 (* 0 (fact (- 0 1))))))))
=> (* 4 (* 3 (* 2 (* 1 (if true 1 (* 0 (fact (- 0 1))))))))
=> (* 4 (* 3 (* 2 (* 1 1))))
=> (* 4 (* 3 (* 2 1)))
=> (* 4 (* 3 2))
=> (* 4 6)
=> 24
```

...