Hello I was wondering if someone could help me with a family tree function in scheme. What I have right now is:

;;proper-blue-eyed-ancestor?: ftn -> boolean
;;consumes:an ftn
;;produces:a list of all the eye colors of the people you can get to 
;;from that node
(define (proper-blue-eyed-ancestor? a-ftn)
    [(empty? a-ftn) false]
    [(ftn? a-ftn) (or(proper-blue-eyed-ancestor? 
                        (ftn-father a-ftn))
                    (proper-blue-eyed-ancestor? (ftn-mother a-ftn))
                    (symbol=? 'blue (ftn-eyes a-ftn)))]))

now my problem is the "or" after

(ftn? a-ftn)

causes it to look at the persons u start off with and counts him/her too. For example if the persons name you type in has blue eyes, but his ancestors don't it comes back true, but its supposed to come back false because I only want it to look at the ancestors of that person...any help? oh and putting a "and" in there doesn't work either.

10 Years
Discussion Span
Last Post by MidiMagic

Try testing the parents of the current person, then recurse if neither parent has blue eyes.


You need a helper function to get it started. Put your current code in the helper function, and then have the main function call the helper function on each parent WITHOUT testing the starting person.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.