211 F '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

If you run any of the functions (as opposed to just testing them), comment out the code for running the functions before you submit your solution.

N.B.: Tests are not runs. A test is when you evaluate an expression and compare it to some expected result, while a run is when you evaluate an expression without anticipating any particular result for the expression.

Due date: 10/14 @ NOON

The goal of this problem set is to continue your study of the use self-referential data definitions such as lists.

You should also learn to deal with list abbreviations so that it becomes easier to enter data in DrScheme. You may use them if you wish; if so, it's probably best if you do 13.0.8 first. Because learning Scheme is not a goal of this course, however, you may continue entering data in a complicated and time-consuming manner.

HtDP Problems:

10.2.2, 10.2.3, 13.0.8 (page 187, optional)

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: see Problem Set 3 (1).

Your task is to develop a function that when given a list of DBRs produces a list of addresses.

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: Lookup the function substring in HelpDesk.

Additional Problem 3:

All of our definitions for lists include the empty list. Here is a data definition for a non-empty list of symbols:

;; A NELOS (non-empty list of symbols) is one of: 
;; -- (cons Symbol empty)
;; -- (cons Symbol NELOS)

It is self-referential but differs from things you have seen in HtDP.

Make up examples of NELOS.

Create a general template for functions that consume an element of NELOS.

Design the function find1, which consumes an NELOS and determines whether 'Mary is on it.

Design the function find, which consumes a list of symbols and determines whether 'Mary is on the list.

Additional Problem 4:

Here is a rather unusual data definition:

(define-struct branch (left right))
;; A NOO is one of: 
;; -- 'LEAF
;; -- (make-branch NOO NOO)

Design the function count, which consumes a NOO and counts how many leafs it has.

Hint: Do not bother to solve this exercise if you're not following the design recipe. Those of you who do, don't share with the others how easy it all is.

Practice Problem [no credit]:

Design sort-by-name. The function consumes a list of DBRs (see Problem 1 above). It produces a version of the list that is sorted by last name.

Hint: Look up string<? in HelpDesk.

last updated on Sat Nov 26 15:34:41 EST 2005generated with PLT Scheme