I don't feel too difficult of project 2 but I have to work hard for it. For instance, I have to figure out how to write two more check-expect expressions for strict-interpolate.
(define (strict-interpolate f n1 n2)
(min (max n1 n2)
(max (min n1 n2) (interpolate f n1 n2))))
(check-ecpect (strict-interpolate 3/2 0 5) 5)
(check-expect (strict-interpolate 3/2 5 0) 5)
To fix interpolate-color(find the minimum or maximum number),we need to write like that:
(define (interpolate-color f c1 c2) c1)
(make-color (interpolate f (color-red c1) (color-red c2))
(interpolate f (color-green c1) (color-green c2))
(interpolate f (color-blue c1) (color-blue c2))
(interpolate f (color-alpha c1) (color-alpha c2)))
To fix arrow-event:
fix arrow-event
(define (arrow-event n k)
(cond [(enqual? k "left") (sub1 n)]
[(equal? k "right") (add1 n)]
[else n]))
In conclusion, it looks like that it is shorter than project 1 but we still need to understand the codes and use them in Dr. Racket.
没有评论:
发表评论