複数のマルチフィールドファクトの複数のスロットに基づいて値を計算するこの関数があります。
かなりの数のスロットが関係しており、それらすべてが関数で必要とされるため、次のように、ファクト全体を関数に渡してそのスロットにアクセスできるかどうかを考えていました。
(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を使用。