# CS 2010 Lab 2 Instructor Plan

1. Evaluate by hand:
```(define (h x)
(* 7 x))
(h 10)```
2. Evaluate by hand:
```(define (f a)
(* 7 (cond
[(= a 3) 9]
[(= a 4) 10])))
(f 3)```
3. Evaluate by hand:
```(define (t a)
(* 7 (cond
[(= a 3) 9]
[(= a 4) 10]
[else 11])))
(t 5)```
4. Evaluate by hand:
```(define (g a b c)
(make-posn 10 (posn-y (cond
[(= c 12) a]
[else b]))))
(g (make-posn 1 2) (make-posn 3 4) 11)```
5. Write the function order which takes two numbers and produces a posn containing the two numbers. The X part of the posn should contain the smaller number, and the Y part the larger.
• (order 10 11) = (make-posn 10 11)
• (order 7 5) = (make-posn 5 7)
6. Write the function max-part, which takes a posn and returns either the X or Y part, whichever is larger.
• (max-part (make-posn 10 11)) = 11
• (max-part (make-posn 7 5)) = 7

For the programs, don't bother with a lab2 handin.

We haven't yet talked about the design recipe for compound data in lecture. So you should suggest the following guideline: when they're writing a function that consumes a posn p, they should write (posn-x p) and (posn-y p) as a start for the function body.

 Last update: Wednesday, August 27th, 2003mflatt@cs.utah.edu