Search code examples
expert-systemclips

compare to nil in clips


How do I compare to nil in clips ?
I have tried

(defrule update-time                                                        
    ?cur-time <- (current-time ?time)                                           
    (order (event-time ?new-time-o&:(neq ?new-time-o nil)))     

I have also tried

(neq ?new-time-o "nil")

none of it seems to work, I get no activation.


Solution

  • You haven't provided enough information to answer your question. Given the appropriate data, this rule will activate:

    CLIPS> (deftemplate order (slot event-time))
    CLIPS> 
    (defrule update-time                                                        
       ?cur-time <- (current-time ?time)                                           
       (order (event-time ?new-time-o&:(neq ?new-time-o nil)))    
       =>)
    CLIPS> (assert (order (event-time (time))))
    <Fact-1>
    CLIPS> (assert (current-time (time)))
    <Fact-2>
    CLIPS> (agenda)
    0      update-time: f-2,f-1
    For a total of 1 activation.
    CLIPS>