Don't bother. I found the answer already: "accumulate" Martijn
Hi, How can I make Jess keep track of changes in working memory with respect to query-results automatically? For example: I have the following code: (clear) (watch all) (deftemplate fact (slot id)) (defquery countfacts (fact (id ?id))) (defrule exec ;(fact) (test (> (count-query-results countfacts) 2)) => (printout t "There are more than 2 facts in WM." crlf) ) (defrule firstfact (not (fact (id ?id))) => (assert (fact (id 1))) ) (defrule nextfact (fact (id ?id&:(< ?id 3))) => (assert (fact (id (+ ?id 1)))) ) (reset) (run) The rule 'exec' will not fire without a prior conditional-element (like (fact) ), because the query is evaluated once, directly after reset, before new facts are asserted, and is not reevaluated when more facts become available, unless the rule has a reason to reevaluate the query by adding the extra condition. Is it possible to have Jess reevaluate aggregate functions like counts, sums and averages automatically without having to think about when it would be a convenient time or status to evaluate a query? (I am aware of the performance issues this might cause). Cheers, Martijn Disclaimer Dit bericht met eventuele bijlagen is vertrouwelijk en uitsluitend bestemd voor de geadresseerde. Indien u niet de bedoelde ontvanger bent, wordt u verzocht de afzender te waarschuwen en dit bericht met eventuele bijlagen direct te verwijderen en/of te vernietigen. Het is niet toegestaan dit bericht en eventuele bijlagen te vermenigvuldigen, door te sturen, openbaar te maken, op te slaan of op andere wijze te gebruiken. Ordina N.V. en/of haar groepsmaatschappijen accepteren geen verantwoordelijkheid of aansprakelijkheid voor schade die voortvloeit uit de inhoud en/of de verzending van dit bericht. This e-mail and any attachments are confidential and are solely intended for the addressee. If you are not the intended recipient, please notify the sender and delete and/or destroy this message and any attachments immediately. It is prohibited to copy, to distribute, to disclose or to use this e-mail and any attachments in any other way. Ordina N.V. and/or its group companies do not accept any responsibility nor liability for any damage resulting from the content of and/or the transmission of this message.