Homework 3
Language: Beginning Student with List Abbreviations
1 Family Trees
; A ftn is either |
; - 'unknown |
; - (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, |
; but where a person does not count as their own ancestor |
; (This is exercise 14.1.6 from HtDP.) |
(define (proper-blue-eyed-ancestor f) ---) |
|
; eye-colors : ftn -> (listof symbol) |
; 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 -> (listof symbol) |
; 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) ---) |
2 Lists of people
; A person is |
; - (make-person symbol number symbol) |
(define-struct person (name date eyes)) |
|
; A list-of-person is either |
; - empty |
; - (cons person list-of-person) |
Write the following function:
; linearize : ftn -> list-of-person |
; returns a list of the people in ‘f’ such that |
; the earlier elements in the list are all younger |
; than the later ones |