211 F '04
Set 1
Set 2
Set 3
Set 4
Set 5
Set 6
Set 7
Set 8
Set 9
Set 10
Set 11
Set 12
Set 13
Set 14

Problem Set 5

Due date: 10/13 @ 6:00 pm

This problem set is about dealing with lists and other kinds of self-referential data definitions.

You will also learn to deal with list abbreviations so that it becomes easier to enter data in DrScheme. You may use them if you wish already; if so, it's probably best if you do 13.0.8 first.

HtDP Problems:

10.2.4, 12.2.1, 13.0.8 (page 187)

Additional Problem 1:

Your boss asked you to write a part of a mass mailing program. He has already specified the central class of data that everyone on his team must use so that the pieces can work together:

(define-struct target (title first last age income))
;; A Target is a structure:
;;   (make-target Title String String Number Number)
;; A Title is one of: 
;; --- false 
;; --- String 

Your task is to develop a function that when given a list of targets produces a list of letters opening. In general, a letter opening starts with "Dear" followed by personalizing material and ending in ":":

Dear Prof. Dr. Clements: 
If a Target contains a proper title string, the letter opening uses the last name only, like the above example. If a Target contains false for the title, a letter opening uses the name only:
Dear John: 

A letter opening never uses both the first and the last name.

Additional Problem 2:

Develop the function truncate, which truncates all lines in a mail message that are more than 80 characters wide. A mail message is a list of lines; each line is a string.

Hint: The function substring consumes a string and two numbers and uses these numbers to extract a portion of the string. Experiment to find out what it does and use it to solve the problem.

Additional Problem 3:

Develop a function that extracts the content from a Russian Easter egg.

(define-struct reg (deep))
;; A Russian Easter egg (REG) is one of: 
;; --- symbol
;; --- (make-reg REG)

Practice Problem [no credit]:

Develop a function that when given a list of colors, create a bull's eye from these colors. Each ring has a width of 10 pixels; the interior of the bull's eye is always a black disk with radius 10. Hint: length counts how many items are on a list.


> (bulls-eye (cons 'green (cons 'red empty))) 

last updated on Mon Nov 29 11:44:30 EST 2004generated with PLT Scheme