Pergunta

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))
Foi útil?

Solução

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> 
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top