HtDP Problem Set
Use the following data and structure definitions to solve this problem.A Document-summary is one of
- (make-letter Symbol Symbol Symbol)
- (make-memo Symbol Symbol Symbol Symbol)
- (make-resume Symbol Symbol Boolean)
(define-struct letter (to date signature))
(define-struct memo (from to date subject))
(define-struct resume (name date sent?))
Develop the function from, which consumes a Document-summary and produces a symbol representing the author of the document (use the
signatureproperty of a letter, the
fromproperty of a memo, and the
nameproperty of the resume).
Develop data and structure definitions for a collection of 3D shapes. The collection includes
- cubes whose relevant property is the length of an edge;
- prisms which are rectangular solids and whose relevant properties are length, width, and height;
- spheres whose relevant property is the radius.
Develop the function volume. The function consumes a 3D shape and produces the volume of the object.
The volume of a cube is the cube of the length of one of its edges. The volume of a prism is the product of its length, width, and height. The volume of a sphere is 4/3 * PI * r3.
Develop data and structure definitions for trains. A train is one of
Develop the function hold-all? that, given a train and a number of passengers, produces
- commuter, which has the properties: number of cars, number of passengers per car, and a boolean determing whether this particular train makes all stops;
- amtrak, which has the properties: number of cars, number of passengers per car, and a symbol designating the type of train as 'Express, 'Local, or 'Limited;
- subway, which has the properties: number of cars, number of passengers per card, and a symbol represeting the color of the train.
trueif the train could contain them all and
Develop data and structure definitions for school employees. An employee is one of
- principal with properties of monthly salary, office number, and a symbol represting the diploma or degree earned by the principal;
- teacher with properties of monthly salary, room number, and a symbol represting the diploma or degree earned by the teacher;
- assistant with properties of hourly wage and number of hours worked within a pay period.
The payroll office needs to compute various taxes before printing a paycheck. Develop the function tax, which takes an employee structure and a tax rate and returns the amount of tax for the pay period (per month for principals and teachers and the hours worked for an assistant).
Develop data and structure definitions for financial accounts. An account is one of
- checking with two properties: balance and number of transactions;
- savings with two properties: balance and number of transactions;
- credit with three properties: balance, spending limit, and number of transactions.
Develop a data definition for a response. A response is either 'Error or an account.
Develop the function withdrawal, which consumes an account and an amount and produces a response. In the case in which a withdrawal would cause the balance of a savings account to go below zero, 'Error would be produced. Otherwise a new savings account would be produced with a new balance and the number of transactions incremented by one. A checking account has overdraft protection up to $1000, so a withdrawal would signal 'Error if the balance were lower than $-1000. A credit account's balance increases upon withdrawal, but cannot go beyond the spending limit.
|Jamie Raymond||Matthias Felleisen|
23 september 2002