Problem Set 3
Language: Beginning Student with List Abbreviations
Due: 11:59 PM Monday Jan. 28
1 Reversing Lists
| ; A list-of-numbers is either |
| ; - empty |
| ; - (cons number list-of-numbers) |
Write the following function:
| ; reverse-list : list-of-numbers -> list-of-numbers |
| ; reverses the elements of a list of numbers |
| (define (reverse-list lon) ---) |
Note: you should not use the built-in function "reverse" in your solution. |
2 Family Trees
| ; A ftn is either |
| ; - empty |
| ; - (make-child symbol number symbol ftn ftn) |
| (define-struct child (name date eyes mom dad)) |
Write the following functions:
| ; proper-blue-eyed-ancestor : ftn -> boolean |
| ; returns true if ‘f’ has a blue-eyed ancestor, |
| ; where a person does not count as their own ancestor |
| ; and empty family tree branches are assumed to have no |
| ; blue-eyed members |
| ; (This is exercise 14.1.6 in HtDP/1e.) |
| (define (proper-blue-eyed-ancestor f) ---) |
| ; a list-of-symbols is either |
| ; - empty |
| ; - (cons symbol list-of-symbols) |
| ; eye-colors : ftn -> list-of-symbols |
| ; returns a list of all of the eye-colors in ‘f’ |
| ; (if there are multiple ancestors with the same eye-colors, |
| ; the list should contain multiple occurrences of the same symbol) |
| (define (eye-colors f) ---) |
| ; no-dup-eye-colors : ftn -> list-of-symbols |
| ; returns a list of all of the eye-colors in ‘f’ |
| ; this list should contain at most one occurrence of |
| ; each different eye-color |
| (define (no-dup-eye-colors f) ---) |