When I carried out all the instructions in
Project #2, DrRacket showed a test failed, which was:
(check-expect
(mouse-event 5 89 57 "button-down")2)
Then,
I used its definition to check again; its definition is:
(define
(mouse-event n x y e)
(cond
[(equal? e "button-down")
(quotient (* x DENOM) (* 3 (image-width p1)))]
[else n]))
But
I still got the same answer. I left this question there. After 20 minutes, I suddenly
remembered that the width of picture p1 has changed, since the original picture
becomes half of it. So, the previous definition
(define p1 (scale 0.5 *))
is
the key to solve this problem.
From this problem, I learn that it is very important to check
previous definitions, when you use them to define a new function.
No comments:
Post a Comment