;; gather-green-eyed: person -> list-of-string ;; returns a list of the names of all people in the tree who have ;; green eyes (define (gather-green-eyed adt) (cond [(symbol=? (person-eye adt) 'green) (cons (person-name adt) (gather-green-eyed-list (person-children adt)))] [else (gather-green-eyed-list (person-children adt))])) ;; gather-green-eyed-list: list-of-person -> list-of-string ;; consumes a list of person and produces a list of names of all ;; those people who have green eyes (define (gather-green-eyed-list alop) (cond [(empty? alop) empty] [(cons? alop) (append (gather-green-eyed (first alop)) (gather-green-eyed-list (rest alop)))])) ;; find-person: string person -> person OR false ;; consumes a name and a person and returns the person with ;; the given name or false if named person not found (define (find-person name aper) (cond [(string=? name (person-name aper)) aper] [else (find-in-list name (person-children aper))])) ;; find-in-list: string list-of-person -> person OR false ;; consumes a name and a list of person and returns the ;; person with the given name or false if no such person found (define (find-in-list name alop) (cond [(empty? alop) false] [(cons? alop) (cond [(person? (find-person name (first alop))) (find-person name (first alop))] [else (find-in-list name (rest alop))])]))