[plt-scheme] HTDPExercise 14.1.3

From: aditya shukla (adityashukla1983 at gmail.com)
Date: Wed Jun 10 16:47:58 EDT 2009

I was solving  this exercise from htdp , its been quite some days since i
wrote a program in scheme .I am getting this error which i am not able to
sort out .Can someone please help me with this.

;data definition
(define-struct child (father mother name date eyes))
;oldest generation
(define Carl (make-child empty empty 'Carl 1926 'green))
(define Bettina (make-child empty empty 'Bettina 1926 'green))

;; Middle Generation:
(define Adam (make-child Carl Bettina 'Adam 1950 'yellow))
(define Dave (make-child Carl Bettina 'Dave 1955 'black))
(define Eva (make-child Carl Bettina 'Eva 1965 'blue))
(define Fred (make-child empty empty 'Fred 1966 'pink))

;; Youngest Generation:
(define Gustav (make-child Fred Eva 'Gustav 1988 'brown))

;A family-tree-node (short: ftn) is either

 ;  1.

   ;  empty; or

    ;  (make-child f m na da ec)
     ; where f and m are ftns, na
      ;and ec are symbols, and da is a number.
;contract of count-persons ftn(family tree node) -> number
;Purpose :This function takes a family tree node and computes the number of
persons in that node
;examples empty -> 0 ,carl ->1 , bettina -> 1 ,  adam , dave , eva -> 3 ,
fred->1 , gustav-> 5
;template(define count-persons (lambda (ftn) (cond [(empty? ftn )][else
(count-persons (child-father ftn)) (count-persons (child-mother  ftn))
(child-name ftn) (child-date ftn) (child-eyes ftn)])))
(define (count-persons  a-ftree)
    [(empty? a-ftree) 0]
    [else ((symbol? (child-name a-ftree))  (+ 1 (count-persons(or (child?
(child-father a-ftree) ) (child? (child-mother a-ftree) )))))]))

(count-persons Fred)

function call: expected a name after an open parenthesis, but found
something else

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20090610/ff11c64a/attachment.html>

Posted on the users mailing list.