剪辑不等于

时间:2014-05-18 16:30:36

标签: clips equals-operator

使用Clips编程语言,正确的"不等于"语法?

这是非符号~

Clips Documentation

1 个答案:

答案 0 :(得分:0)

〜约束是模式匹配语言的一部分。 neq函数用于表达式。两者都可以与任何类型的值一起使用。 !=和<>函数只能与数字参数一起使用。

CLIPS> (clear)
CLIPS>  
(defrule rule-1
   (color ?color&~red&~blue)
   =>
   (printout t "rule-1: " ?color crlf))
CLIPS>  
(defrule rule-2
   (color ?color)
   (test (and (neq ?color red) (neq ?color blue)))
   =>
   (printout t "rule-2: " ?color crlf))
CLIPS> (assert (color green) (color blue) (color yellow) (color red))
<Fact-4>
CLIPS> (run)
rule-1: yellow
rule-2: yellow
rule-1: green
rule-2: green
CLIPS> (neq 2 3)
TRUE
CLIPS> (neq a b)
TRUE
CLIPS> (!= 2 3)
TRUE
CLIPS> (!= a b)
[ARGACCES5] Function != expected argument #1 to be of type integer or float
CLIPS>