我有这个函数,它根据多个多字段事实的多个槽计算一些值。
因为涉及到相当多的插槽,并且函数中需要所有插槽,所以我在想是否可以将整个事实传递给函数并访问其中的插槽,如下所示:
(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。