代码之家  ›  专栏  ›  技术社区  ›  langlauf.io

clips:类实例匹配周围没有条件元素

  •  1
  • langlauf.io  · 技术社区  · 6 年前

    我读到了

    clips还提供了在lhs上指定显式非条件元素的功能。 事实的缺失被指定为lhs上使用“not”条件元素的模式。

    但是,下面的代码给了我一个 [PRNTUTIL2] Syntax Error: Check appropriate syntax for the not conditional element.

    (not
        (object (is-a clips_ASDF)
            (name ?some_name)
            (property ?my_property_var))
        (test (eq ?my_property_var nil)))
    

    但这不会导致错误:

        (object (is-a clips_ASDF)
            (name ?some_name)
            (property ?my_property_var))
        (not
            (test (eq ?my_property_var nil)))
    

    为什么会这样?我该怎么做?

    2 回复  |  直到 6 年前
        1
  •  2
  •   Gary Riley    6 年前

    这个 条件元素只能是单个条件元素。如果要放置多个,请用 条件元素:

       (not (and (object (is-a clips_ASDF)
                         (name ?some_name)
                         (property ?my_property_var))
                 (test (eq ?my_property_var nil))))
    

    或者,不需要单独 测试 条件元素:

       (not (object (is-a clips_ASDF)
                    (name ?some_name)
                    (property nil)))
    
        2
  •  1
  •   Nicola Ben    6 年前

    这应该符合您的需要:

    (defrule my-rule      
        (object (is-a clips_ASDF) (name ?some_name) (property ?my_property_var)&:(neq ? my_property_var nil))
        =>
        (printout t "done" crlf))