In Jess, suppose my Factbase consists of several name-value pairs like
(node1 6.5) (node2 100) (node3 0.5)
How can I achieve to "update" the values for example the "node1" value from 6.5 to 100 without manually retracting it?
Also, is there a way to "reassert" all the facts, after a certain rule is fired?
You use Jess's
(modify)function to modify facts. As explained in the manual, ordered facts like(node1 6.5)are internally represented as unordered facts with a single slot named__data, so you can exploit that knowledge to modify them:Now, given all that, for efficiency I'd still recommend that you use an unordered template like
so that your facts look like
As regards your last question: I'm not quite sure what you mean, but you might look up the
(deffacts)construct and the(reset)function and see if together those will do what you need.