i want to count my facts and that facts will have to be boolean. for my intention i only need count TRUE. My problem is if i assert or use deffact to make 4 facts in one slot for example. the working memory doesn´t read all the facts. i tried putting another slot with another data(names in this case)and work good, but i don´t need another slot. i just do it for try to run this code. is there another option? let me show you:
(deftemplate testing (slot bole)(slot otro))
(watch all)
(defquery search-by-true
"Finds true"
(declare (variables ?ln))
(testing (bole ?ln)(otro ?ot)))
(deffacts data
(testing (bole TRUE)(otro josue))
(testing (bole TRUE)(otro pedro))
(testing (bole FALSE)(otro pablo))
(testing (bole TRUE)(otro carlos))
)
(reset)
(bind ?result (run-query* search-by-true TRUE))
(bind ?x 0)
(while (?result next)
(bind ?x (+ ?x 1))
)
(printout t (* ?x 0.3) crlf)
My intentions are learn this by then use objects with java code and jess. how i am going to use JCheckbox and this objects are boolean so that´s why i need to understand this please. if you have a good recommendation for me i accept it with humility. Thanks.
If I understand you correctly, you’d like to have working memory contain something like
... and then run some code that told you there are 2 “bole TRUE” facts. This isn’t possible in Jess: working memory cannot contain duplicate facts. If you try to assert a fact that is identical to an existing one, assert returns FALSE and no changes are made to working memory. You could use your extra slot to contain a serial number or some other piece of unique information.