取消引用剪辑中匹配事实中的槽
如何取消引用规则 LHS 中匹配的事实中的槽?如果一个变量 符合事实,我找不到如何创造进一步的条件 该事实中的匹配槽。
例如,在下面的代码中,如果存在“(do (action ?action))”形式的事实,我想打印一些文本。然而, ?action 本身就是一个事实,我只希望当该事实的“名称”槽为“运行”时触发规则。我将如何实现这个目标?
(deftemplate do
(slot action)
)
(deftemplate action
(slot name)
)
(defrule find-do ""
?do <- (do (action ?action))
(test (eq ?action.name "run")) ; This causes a syntax error.
=>
(printout t "doing " ?action crlf)
)
(deffacts startup (do (action (action (name "running")))))
How do you dereference a slot in a fact matched in the LHS of a rule? If a variable
matches a fact, I can't find how to create further conditions that
match slots within that fact.
For example, in the code below, I want to print some text if there's a fact of the form "(do (action ?action))". However, ?action is itself a fact, and I only want the rule to trigger if that fact's "name" slot is "run". How would I accomplish this?
(deftemplate do
(slot action)
)
(deftemplate action
(slot name)
)
(defrule find-do ""
?do <- (do (action ?action))
(test (eq ?action.name "run")) ; This causes a syntax error.
=>
(printout t "doing " ?action crlf)
)
(deffacts startup (do (action (action (name "running")))))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
搜索剪辑参考手册,我终于找到了“fact-slot-value”函数,它似乎可以满足我的要求。
Searching through the Clips Reference manual, I finally found the function "fact-slot-value" that seems to do what I want.