CSci 1301: Problem Set 7

Due: Wednesday, December 10 at 11:59pm by e-mail

You are required to write signatures and descriptions for all functions, and also descriptions of all your structures. Additionally, functions, except the world problems, must be tested using check-expect. Write your tests before you write a function (but feel free to add more after it's been writen).

The quality of your tests will be graded. Make sure to have enough test cases to demonstrate that the function is correct. I may take points off for a lack of testing (in addition to those taken off for incorrect behavior) if your function doesn't work on particular expected data and there is no test for it. It's much better to leave a test that fails (perhaps in comments) that shows that the function doesn't work on given data and you don't know how to fix it.

Self-referential structure (5 points total)

Given the family tree structure in defined in Section 22.1, write a function ft-has-color? that takes a family tree and a color and returns true if that family tree has a person with that color of eyes, and false otherwise.

Generative recursion (12 points total)

Write a function contains-all? that consumes two lists of numbers and returns true if the first list contains all elements of the second one and false otherwise. For simplicity assume that neither list contains the same element more than once.

Write a fucntion common-elements that takes two lists of numbers and returns the list of all elements that appear in both lists. For simplicity assume that neither list contains the same element more than once.

Make sure to write tests before you write the functions. You may use helper functions, local definitions, and general functions (map, filter, etc).


CSci 1301 course web site.