17.E

This worksheet addresses a number of challenging misconceptions. Read closely and consider you answers thoughtfully.

Expanations

You are given some information and asked about other functions. Explain how to write the other functions or why the situation is impossible.

  1. (Big Blue) Moving the mouse makes the blue circle increase its radius by 5.

     (define (maus1 n x y event)
        (+ n 5))
    
    1. Write the signature of the mouse handler maus1.
    2. Write the draw handler.
  2. Using the setup from Big Blue above, the animation stops when the circle’s radius is at least 175.

    1. What is the signature of the stop-when handler’s should-stop? function.
    2. Write the should-stop? function.
  3. (Small Orange) Moving the mouse reduces the orange circle to 95% of its current size. You are given the draw handler is draw2 below.

    1. Based on the draw handler draw2, what is the type of the model?
    2. Write the signature of the mouse handler oshrink.
    3. Write the mouse handler.
(define (draw2 mystery)
   (overlay mystery (empty-scene 300 200)))
  1. (Wide Green) Hitting a key makes the rectangle twice as wide as it was. The draw handler dhwg and the key handler is wg (below).

    1. Write the signature of the function wg, as shown below.
    2. Make/describe a chart showing pressing the “a” key and then the “b” key. Begin with an initial model of 40. What is the model after hitting the “a” key? Then the “b” key? Is this animation going to work ok?
(define (wg model key)
  (rectangle (* 2 model) 50 "solid" "green"))

(define (dhwg model)
  (rectangle model 50 "solid" "green"))
Last modified January 9, 2024: Revisions for clarity. (e821b2a)