How to get information from the fact in CLIPS?

1.4k Views Asked by At

After working function, I get a number of fact, for example: Fact 2. How can I get information about this fact programmatically?

1

There are 1 best solutions below

0
On BEST ANSWER
CLIPS> (clear)
CLIPS> (deftemplate person (slot name) (slot address))
CLIPS> (assert (person (name "Sam Jones") (address "123 Main Street")))
<Fact-1>
CLIPS> (assert (person (name "Sue Smith") (address "456 Maple Drive")))
<Fact-2>
CLIPS> (facts)
f-0     (initial-fact)
f-1     (person (name "Sam Jones") (address "123 Main Street"))
f-2     (person (name "Sue Smith") (address "456 Maple Drive"))
For a total of 3 facts.
CLIPS> (fact-relation 2)
person
CLIPS> (fact-slot-value 2 name)
"Sue Smith"
CLIPS> (fact-slot-value 2 address)
"456 Maple Drive"
CLIPS>