Consider a simplified address book as follows:
(define-struct Address (name city)) (define myAddressBook (list (make-Address "ali" "ankara") (make-Address "ayşe" "istanbul") (make-Address "berk" "ankara"))
Write a function which takes an address book and name of a city, and returns how many of the people in the address book lives in that city. For example:
(define (inCity addresses city) ... ) (check-expect (inCity myAddressBook "ankara") 2)
Create an animation in which a ball stands still (i.e. zero velocity) at bottom-left corner. When mouse is clicked, the ball must start moving at a velocity towards where mouse is clicked, and at a speed which depends on distance of mouse click to ball. But as different from gravity-free animations we have done before, the ball must be exerted to gravity, i.e. its velocity in y direction decreases at every time tick. Feel free to choose the gravity constant in your universe (which may even be negative!).
Feel free to use the single ball animation example as a starting point.
HINT: Since animation is created by ticking about 20 times a second, the following mouse-event handler function can be an appropriate choice, which divides the -ball-to-mouse distance to 20:
(define (handleMouseClick worldState x y event) (cond ((string=? event "button-down") (make-Ball (Ball-radius worldState) (Ball-point worldState) (make-Velocity (/ (- x (Point-x (Ball-point worldState))) 20) (/ (- y (Point-y (Ball-point worldState))) 20)))) (else worldState)))