Adapting http://herzberg.ca.sandia.gov/jess/docs/70/rules.html#accumulate_ce
(defrule a-class-has-more-than-10-methods (class (className ?clsName)) ?total <- (accumulate (bind ?count 0) ; initializer (bind ?count (+ ?count 1)) ; action ?count ; result (method (className ?clsName) (methodName ?mtdName))) (test (> ?total 10)) => (printout t ?clsName " has more than 10 methods" crlf)) Bob Kirby At 09:06 PM 5/24/2007, fan yang wrote: >Hi All, > >Assuming there are two facts, one is a class and another one is a method, >definitions of two facts are: > >(deftemplate class (slot className)) > >(deftemplate method (slot className)(slot methodName)) > >(defrule a-class-has-more-than-10-methods > (class (className ?clsName)) > ; (method (className ?clsName)(methodName ?mtdName) > ; I want to get the number of methods in this class > => > (printout t ?clsName " has more than 10 methods" crlf) >) > >I want to get how many methods in each class, is there a Jess function which >does what I want? If there isn't such function, would you please tell me how >to do it? > >Thanks a lot. -------------------------------------------------------------------- To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED] --------------------------------------------------------------------
