|
Comp210: Principles of Computing and Programming
|
All problems will require all (applicable) steps from the design recipe, including a template. Before you tackle the homework, remind yourself of our General Advice, Advice on Homeworks (in particular: staple and provide questions), and the Grading Guidelines.
A short homework assignment for this week due to the exam.
Remember: Contract, purpose, header and test cases are always required!
Using the following data definition of FamTree (for more details, see Lecture 14 )
;; A FamTree is ;; - Unknown ;; - (make-child sym num FamTree FamTree) ;; Unknown is an empty FamTree (define-struct Unknown (label)) ;; a Child is a structure where ;; name is the name of a person ;; year is their birthyear ;; ma is a FamTree representing the person's mother ;; pa is a FamTree representing the person's father ;; (make-Child sym num FamTree FamTree) (define-struct Child (name year ma pa))
And the following data definition for a Name+Generation tuple:
A NamGen is a (make-NamGen sym num) where name is the name of a person and gen is the generation number as measured from the root of some specified FamTree. That is, the child at the root of the FamTree is gen=0, their parents are gen=1, grandparents are gen=2, etc. (define-struct NamGen (name gen))
Write the function
;; earliest: FamTree --> NamGen ;; Returns the name and generation of the earliest known ;; (farthest back generation) person in the family tree.
;; If there are more than one people with the same earliest ;; generation value, return any one of those people. (define (earliest aFamTree) ...)
GenList can be either just a symbol or a list of lists of lists of.lists of....of symbols.;; A GenList is either a ;; -- symbol ;; -- NSGenList ;;A NSGenList (Non-Symbol GenList) is either ;; -- empty ;; -- (cons GenList NSGenList)
Pondering for the day: What's the difference between a GenList and expressions in Scheme?
90 points total.
Last Revised Tuesday, 24-Aug-2004 13:49:11 CDT
©2004 Stephen Wong and Dung Nguyen