Search code examples
clipsequals-operator

Clips Not Equals To


Using the Clips programming language, what is the correct "not equals" syntax?

This is the not symbol ~

Clips Documentation


Solution

  • The ~ constraint is part of the pattern matching language. The neq function is for use within expressions. Both can be used with values of any type. The != and <> functions can only be used with numeric arguments.

    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>