Ancestor family trees (p 183ish)
DATA DEFINITION -- FIRST [use 'unknown instead of empty for base case]
develop template -- FIRST
now show how easily we can write functions on this:
;; is-in? : symbol family-tree -> boolean
;; count : family-tree -> number
;; count-ww2-babies : family-tree -> number
;; count those born between 1941 and 1945, inclusive
PVD 2001:
This lecture has potential to be a disaster. If you follow the
design recipe to the letter, you end up with the following. A
person is a (make-person symbol number tree tree) and a tree is
either 'unknown or a person. This means they are ... mutually
recursive. Bad idea. That's for tomorrow morning!
Right defn:
A ft-node is either
- 'unknown, or
- (make-person symbol number symbol ft-node ft-node)
(define-struct person (name year eye-color mother father)
|
LAB |