CLIPS:不是 class 实例匹配周围的条件元素
CLIPS: Not conditional element around class instance match
我读到
CLIPS also gives you the capability of specifying an explicit not conditional element on the LHS.
The absence of a fact is specified as a pattern on the LHS using the “not” conditional element.
然而,下面的代码给了我 [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)))
这是为什么?我该怎么做第一个?
这应该符合您的需要:
(defrule my-rule
(object (is-a clips_ASDF) (name ?some_name) (property ?my_property_var)&:(neq ? my_property_var nil))
=>
(printout t "done" crlf))
not条件元素只能can一个条件元素。如果要放置多个,请用 和 条件元素包围它们:
(not (and (object (is-a clips_ASDF)
(name ?some_name)
(property ?my_property_var))
(test (eq ?my_property_var nil))))
或者,不需要单独的 test 条件元素:
(not (object (is-a clips_ASDF)
(name ?some_name)
(property nil)))
我读到
CLIPS also gives you the capability of specifying an explicit not conditional element on the LHS. The absence of a fact is specified as a pattern on the LHS using the “not” conditional element.
然而,下面的代码给了我 [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)))
这是为什么?我该怎么做第一个?
这应该符合您的需要:
(defrule my-rule
(object (is-a clips_ASDF) (name ?some_name) (property ?my_property_var)&:(neq ? my_property_var nil))
=>
(printout t "done" crlf))
not条件元素只能can一个条件元素。如果要放置多个,请用 和 条件元素包围它们:
(not (and (object (is-a clips_ASDF)
(name ?some_name)
(property ?my_property_var))
(test (eq ?my_property_var nil))))
或者,不需要单独的 test 条件元素:
(not (object (is-a clips_ASDF)
(name ?some_name)
(property nil)))