Due date: 10/16
The goal of this problem set is to help you design abstractions and to
deploy pre-defined abstractions in a functional context. In addition, the
assignment should familiarize you with closures.
HtDP: 19.1.5, 20.2.4 (also see 20.2.2), 21.2.1, 21.2.2, 21.2.3
Note: You must use DrScheme's HtDP Intermediate Student
Language with Lambda.
The union of German professors negotiated the following pay scale in 1878:
The base salary is 4,000E. For each five years over the age of 30, a
professor is paid an age bonus factor of two (2) percent over the base
salary; e.g., a 36-year old earns an additional 2% of the base salary.
Furthermore, a married professors receives a 500E bonus. For each
dependent child, the pay is increased by 225.75E.
The contract has been adapted on a yearly basis; e.g., it now specifies Euros
instead of Reichsmark.
The centralized payment office represents a single professor with a
five-field personnel record: first name, last name, year of birth, marital
status (boolean), and the number of children. A pay check record consists
of three pieces: first name, last name, and the monthly gross salary.
Design a function that computes the pay check information from a given
personnel record. You may assume that the current year is specified as a
Design the following functions:
Use existing abstractions where possible.
pay-all, which computes the pay check information for a
list of personnel records;
pay-sum, which computes the total sum paid out for a
list of personnel records; and
pay-order, which creates a list of personnel records
ordered in decreasing order according to salary.
Use the list abstractions from the table on page 313 in HtDP to
simplify the definitions of your solutions of 3.1 and 3.2.
Solve problems 23.4.1, 23.4.2. These problems are about using functions as
Abstract over the similarities in your solutions. Promised there are a
bunch if you followed the design guideline of one function per task. If
not, you better take the time to re-design your program now.
Extend your solution of problem 3.4 so that the simulation works with a
number of balls, not just one.
Design the function
create-world, which consumes a number
N and produces a list of
N random balls located
within the box and moving in random positions. The speed in the
Y direction should be between
+10 but not
0; the speed in the
direction should be anywhere in the same interval, including 0. (Optional:
Design a function that eliminates duplicate balls from this list. Why is
this something that you don't really need?)
For each tick, move all balls according to the laws of exercise 3.4.
When a ball leaves the box through the top, eliminate it from the list.
When all balls are gone, the simulation is over.
Constraint: There is no need to consider collisions of balls. Assume they
may pass through each other.