【问题标题】:How do I bind the value of a global variable to a slot?如何将全局变量的值绑定到插槽?
【发布时间】:2019-06-10 06:27:46
【问题描述】:

我正在尝试将插槽绑定到全局变量,但似乎不起作用。

我已尝试以下方法,但我创建的规则不起作用。

*(defrule getusermalinfo
(user  (usinfo  ?usr))
=>
(bind ?usr ?*degreeofyes*)  
)*

之后,我想使用槽值做出一些决定。就像下面的规则:

*(defrule not-likely
(user {usinfo <= 10})
=>
(printout t "Not suffering from Kwashiorkor" crlf)
)*

【问题讨论】:

    标签: clips jess


    【解决方案1】:

    不能使用(绑定)来修改事实的槽值。你需要使用(修改),像这样:

    (defrule getusermalinfo
      ?user <- (user)
     =>
      (modify ?user (usinfo ?*degreeofyes*))
    )
    

    但是请注意,您可能必须在此规则的 LHS 中添加一些内容以选择某些特定的用户事实和/或避免在修改后重复触发此规则。

    【讨论】:

    • 感谢@laune 工作,但在我看到重复效果时会考虑您的笔记。
    猜你喜欢
    • 2020-01-01
    • 1970-01-01
    • 2014-10-18
    • 2010-11-21
    • 2023-03-03
    • 1970-01-01
    • 1970-01-01
    • 2012-11-09
    • 1970-01-01
    相关资源
    最近更新 更多