Question

Is there a way for me to get the fact ID of a fact that I just asserted in the RHS of a rule? Something along the lines of

?f <- (assert (new-fact))
Was it helpful?

Solution

CLIPS> 
(defrule example
   =>
   (bind ?f (assert (new-fact)))
   (bind ?i (fact-index ?f))
   (printout t "The fact index is " ?i crlf))
CLIPS> (reset)
CLIPS> (run)
The fact index is 1
CLIPS> (facts)
f-0     (initial-fact)
f-1     (new-fact)
For a total of 2 facts.
CLIPS> 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top