Here are two equally correct, but radically different versions of the same function. Inspect the one on the right before you read the one on the left:
| recommended | as seen in code walks (average) |
|---|---|
(define (??? a-ball)
(cond
[(hitwall? b) (reflect (straight a-ball 1.))]
[else (straight a-ball 1.)]))
|
(define (??? b)
(cond
[(and (≤ YUP (where b) YLO)
(or (≤ (ball-x b) XWALL
(+ (ball-x b)
(ball-dx b)))
(>= (ball-x b) XWALL
(+ (ball-x b)
(ball-dx b)))))
(make-ball
(- (* 2 XWALL)
(ball-x (straight b 1.)))
(ball-y (straight b 1.))
(- (ball-dx (straight b 1.)))
(ball-dy (straight b 1.)))]
[else (straight b 1.)]))
|
Last modified: Sun Dec 21 16:47:24 Eastern Standard Time 2008