从 deffunction 中的多字段访问插槽
我有这个函数,它根据多个多字段事实的多个槽计算一些值。
因为涉及相当多的槽,并且函数中需要所有槽,所以我在想是否可以将整个事实传递给函数并访问其中的槽, 像这样:
(deftemplate a-fact
(slot id)
(slot name)
(slot ...)
...
)
(deffunction a-funciton (?factadr)
(switch ?factadr:name
(case bla then ...)
)
(return ?calculated-value)
)
(defrule a-rule
?factadr <- (a-fact (id ?i))
=>
(if (> **(a-function ?factadr) 20) then ... )
)
我在这个例子中看到了这个 ?fact-adrres:slot-name 并认为它会起作用,但事实并非如此。那么,是否可能以及如何做到呢?
(bind ?facts (find-all-facts ((?f attribute))
(and (eq ?f:name wine)
(>= ?f:certainty 20))))
使用剪辑6.3。
I have this function which calculates some value based on multiple slots of multiple multifield facts.
Because quite some slots are involved and all of them are needed in the function I was thinking if I could pass a whole fact to a function and access its slots in it,
like so:
(deftemplate a-fact
(slot id)
(slot name)
(slot ...)
...
)
(deffunction a-funciton (?factadr)
(switch ?factadr:name
(case bla then ...)
)
(return ?calculated-value)
)
(defrule a-rule
?factadr <- (a-fact (id ?i))
=>
(if (> **(a-function ?factadr) 20) then ... )
)
I saw this ?fact-adrres:slot-name in this example and thought it will work but it doesn't. So, is it possible and how to do it?
(bind ?facts (find-all-facts ((?f attribute))
(and (eq ?f:name wine)
(>= ?f:certainty 20))))
Clips 6.3 is used.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用事实槽值函数。
Use the fact-slot-value function.