CLIPS:如果是INSTANCES,则从多时隙中检索槽值

时间:2016-12-12 17:25:21

标签: clips

我有一个具有多个INSTANCE的对象。 我通过一次调用获取实例的插槽时遇到问题。 例如:

(defclass AUTOMA (is-a USER)
(slot uuid))

(defclass TUTOMA (is-a USER)
(multislot list 
(type INSTANCE)))


(make-instance A1 of AUTOMA
(uuid a1))
(make-instance A2 of AUTOMA
(uuid a2))
(make-instance T1 of TUTOMA
(list [a1] [a2]))

我想要检索多时隙列表的第一个对象uuid。

1)尝试使用“first $”:

CLIPS> (first$ (send [T1] get-list))
([a1])
CLIPS> (send (first$ (send [T1] get-list)) get-uuid)
[MSGFUN1] No applicable primary message-handlers found for get-uuid.
FALSE

2)尝试使用“implode $”:

CLIPS> (implode$ (first$ (send [T1] get-list)))
"[a1]"
CLIPS> (send (implode$ (first$ (send [T1] get-list))) get-uuid)
[MSGFUN1] No applicable primary message-handlers found for get-uuid.
FALSE

似乎([a1])和“[a1]”都不适合(发送XXX get-uuid)命令。 有什么建议吗?

谢谢 NIC

1 个答案:

答案 0 :(得分:1)

First $返回一个多字段值,implode $返回一个字符串。您需要使用实例名称。使用nth $从多字段中检索字段。您还需要保持用于实例名称的案例保持一致:

min_query = "SELECT PERSON_NAME, MIN(SCORE) FROM HTMLSCORES"

cursor.execute(min_query)

result = cursor.fetchone()
name = result[0]
min_score = result[1]