Parameters for Structs in Scheme
I have this struct for people:
(define-struct person
(
fir开发者_StackOverflow社区st ; 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
(structname-fieldname struct)
So for your example:
(person-last P-00000)
精彩评论