Design a program that computes the number of insulin units from a given
blood-level. See Problem Set 1(2) for the
problem statement. Hint: Explore the function quotient of two numbers.
Once you have a first draft, make sure that the function doesn't produce
Your manager wants a running dot: a solid red dot that runs on a monitor from
left to right, disappears on the right, and re-appears on the left.
For the first and last quarter of the band, the dot is to move at 4 pixels per
second; in the middle sector its speed is 8 pixels per second. Your manager has
decided to represent the running dot as just an number:
;; TeachPack: world.ss
;; World = Number
;; interpretation: the distance of the center from the left
(define WORLD-WIDTH 100)
Design the function next, which consumes the current x
coordinate of the dot and computes where the dot will be next. --- Ensure that
changing the width of the band can be accomplished with a single modification
of the program.
Design the function draw, which consumes the current x
coordinate and produces a scene of 300 x 20 pixels with the red dot at the
appropriate spot. The red dot should always have a diameter equal to the height
of the scene. (How should you do this so that a change to the height changes
the red dot's appearance, too?) Hint: Look up world.ss in HelpDesk.
Add the following code fragment at the bottom of your program and fill in the
dots to get the red band to run:
Do not attempt this before you have finished the design of the
;; --- run program run ---
;; World -> World
;; on every tick of the program:
(define (tock w) (update (draw w) produce (next w)))