Homework 3
Due Wednesday, October 21 by 3pm.
Language: Beginning Student with List Abbreviations
1 Family Trees
; A ftn (family tree node) is either
; - 'unknown
; - (make-child symbol number symbol ftn ftn)
(define-struct child (name date eyes mom dad))
Here name is a symbol, date is a number denoting the date of birth, eyes is a symbol and mom and dad are of type ftn.
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 (How to Design Programs textbook).)
(define (proper-blue-eyed-ancestor f) ---)
; eye-colors : ftn -> (listof symbol)
; returns a list of all of the eye-colors of ancestors of '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 of ancestors of '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' ('f' and all its ancestors)
; sorted by their dates of birth in the ascending order
; ftn stands for family tree node as in previous exercise and 'f' is of type ftn
|