211 S '05
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: 2/7 @ 4:30 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 emailing 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 (name login domain age)
;; A Target is a structure:
;;   (make-target Name String String Number)
;; A Name is one of: 
;; --- false 
;; --- String 

Your task is to develop a function that when given a list of targets produces a list of email addresses. In general, an email address is a Name followed by an address formed from the login and/or domain. For example:

<Jeffrey Palm> palm
If a Target contains a proper name string, the address begins with name surrounded by '<' and '>' followed by the login, like the above example. If a Target contains false for the name, an address uses the login and domain only separated by a '@':

An email address never uses both the name and domain.

Additional Problem 2:

Develop the function prefix, which adds the character '>' and a space to all lines in a mail message that do not already begin with '>'. 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 shell (yolk))
;; A Russian Easter egg (REG) is one of: 
;; --- symbol
;; --- (make-shell 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))) 


Please explain any problems you had completing this assignment in no more than 30 words.

last updated on Wednesday, April 13th, 2005 3:57:37pmgenerated with PLT Scheme -- (Source)