gpt4 book ai didi

方案中结构体的参数

转载 作者:行者123 更新时间:2023-12-01 17:26:02 25 4
gpt4 key购买 nike

我有一个供人们使用的结构:

(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
)
)

然后我让人:

(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

我现在如何访问结构体中的特定参数。举例来说,我想显示 P-00000 的姓氏,我该怎么做?

谢谢

最佳答案

(structname-fieldname struct)

举个例子:

(person-last P-00000)

关于方案中结构体的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4009920/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com