views:

43

answers:

1

I have this struct for people:

(define-struct person  
    (  
    first    ; a string: first name  
    last     ; a string: last name  
    sex      ; a symbol: 'male, 'female  
    eyes     ; a symbol: 'blue, 'brown', 'green  
    hair     ; a symbol: 'blonde, 'brown, 'black, 'red  
    mother   ; a person: empty if not known  
    father   ; a person: empty if not known  
    born     ; a number: year of birth  
    )  
)

and then I make people:

(define P-00000 (make-person "Alexandra" "Harper" 'female 'blue 'red empty empty 1897))  
(define P-10000 (make-person "Joshua" "Sherman" 'male 'green 'blonde empty empty 1881))  
; ... etc

How can I now access specific paras in the struct. Say for example I want to display the last name of P-00000 how can I do that?

Thanks

+4  A: 
(structname-fieldname struct)

So for your example:

(person-last P-00000)
sepp2k
For more details, see section 6.3 of HtDP: http://www.htdp.org/2003-09-26/Book/curriculum-Z-H-9.html#node_sec_6.3
John Clements