### Problem Set 5

Programming Language BSL

Purpose This problem set (primarily) concerns the design of functions on self-referential data definitions.

You must follow the design recipe. The graders will look for data definitions, contracts, purpose statements, examples/tests, and properly organized function definitions. For the latter, you must design templates. You do not need to include the templates with your homework, however. If you do, comment them out.

You might also note that your graders are now being instructed to grade off for gruesomely laid-out code; proceed accordingly.

Finger Exercises HtDP/2e: 166, 167, 168, 169, 171, 172, 173, 174, 175, 176; in preparation of the next exam, consider solving any of the extended exercises in chapter 13. (As usual, "finger exercises" will not be graded; they are just for you to practice on.)

Problem 1

You are designing software for the post office to help process physical mail. There are two kinds of physical mail: letters and boxes. A letter has an address (which we’ll represent simply, as a string) and a weight (measured in ounces). A box has height, width and length dimensions (measured in inches) and a weight (measured in ounces).

There are some rules for mail:
• A letter must weigh less than 3.5 ounces.

• The sum of a box’s height, width and length must be 62 inches or less, its total volume must be 7938 cubic inches or less, and its weight must be 50 pounds (800 ounces) or less.

• A letter costs fifty cents to mail, while a box is fifteen cents an ounce.

Here are the tasks before you:
1. Design a data definition, Item, to represent one item of mail.

2. Design a function, item-ok?, to determine if a piece of mail satisfies the rules.

3. Design a data definition, LOI, for a list of items.

4. Design a function, bad-items, that takes a collection of mail (represented as an LOI), and returns all the items that don’t satisfy the rules.

5. Design a function, total-postage, that produces the total postage for a collection of mail.