The goal of this problem set is to practice designing data representations
using structures and functions for processing such forms of
data. Furthermore, you must follow the design recipe and the guidelines
when you develop functions.
Note that you have to work on this problem set
with your assigned partner. Partner assignments are posted on the blog.
Consider the following structure definition:
and evaluate the following expressions:
(define-struct automobile (year make model))
(automobile-year (make-automobile 2010 'Porsche 'Boxster))
(automobile-make (make-automobile 2002 'Saab 'Viggen))
(automobile-model (make-automobile 2011 'Toyota 'Prius))
Now evaluate the following expressions, assuming a and b stand for arbitrary symbols:
(automobile-model (make-automobile 2012 a b))
(automobile-make (make-automobile 2012 a b))
Formulate equations that state general laws concerning the relationships of
Provide a structure definition and a data definition for representing
points in time since the beginning of the week. A point in time consists of three
numbers: days, hours, and minutes. (A week begins at 00:00 on Sunday.)
Develop the function
time->minutes, which consumes a time structure
(see Problem A2) and produces the number of minutes since the beginning of the week
that the time structure represents.
(time->minutes (make-time 2 10 19))
;; expected value:
Explain the example.
In many parts of the world, UFOs have been abducting
cows. This should not surprise you, as you are a UFO
pilot who has been sent on just such a mission. As you
have probably been warned, however, the base of your
UFO is made of a special alloy that cannot be allowed
to come in contact with the ground. Your task,
therefore, is to land your UFO atop a cow without
crashing on Earth... which, as you may have heard,
can turn you into a participant in certain
The goal of this problem set is to practice designing
data representations using structures and functions
for processing such forms of data.
How the game works:
A cow is placed at an initial position on the bottom
of the screen. The cow moves left at a fixed speed
until hitting the left side of the screen at which
point it changes direction and moves to the right until
hitting the right side, and so on.
A UFO is placed at an initial position at the top of
the screen. The UFO moves downward at a fixed rate.
The UFO can be moved left/right by pressing the
left/right arrow keys.
The game is over when the UFO hits the ground or the cow.
The game should indicate in some way whether the game
was won (UFO hits cow) or lost (UFO hits ground).
Cows and UFOs
Design a data definition for UFOs and Cows.
A UFO has an X and a Y coordinate.
A Cow has an X coordinate and is either going left or right.
Define a function that moves a UFO down by some fixed amount.
Define a function that moves a UFO either left or right by some
Define a function that moves a Cow in the direction it is going
by some fixed amount.
Define a function that determines if a Cow is at the edge of
Define a function that flips the direction of a Cow.
Define a function that moves a Cow in the direction it is going,
unless it at the edge, in which case, the Cow should flip directions,
and then move.
Define a function that determines if a UFO has captured a Cow.
Define a function that determines if a UFO has crashed on the ground.
Define a function that determines if the game is over.
Define a data definition for Worlds.
A World has a UFO and a Cow in it.
Define a function that handles key events (maybe moving the
UFO left / right).
Define a function that renders the World as a Scene.
Define a function that "ticks" the world (moves the UFO
down and moves the Cow).
Use the big-bang system to start the game.