Qiu Xue
Qiu Xue

Reputation: 163

trying to retract facts when using clips

I am new to clips, I found that my retract not really delete the facts.

(defrule test
(select ?select~indoor&~outdoor)
=>
(retract ?select)
)

After the clips run this code, I try to check by using (facts),but I still found that the facts select is still there

Upvotes: 0

Views: 893

Answers (1)

Gary Riley
Gary Riley

Reputation: 10757

You need to bind a variable to the fact matching the pattern. You can't retract the fact by binding a variable to a value inside the fact.

         CLIPS (6.31 2/3/18)
CLIPS> 
(defrule test
   ?f <- (select ...)
   =>
   (retract ?f))
CLIPS> (assert (select ...))
<Fact-1>
CLIPS> (facts)
f-0     (initial-fact)
f-1     (select ...)
For a total of 2 facts.
CLIPS> (run)
CLIPS> (facts)
f-0     (initial-fact)
For a total of 1 fact.
CLIPS> 

Upvotes: 1

Related Questions