I am trying to find the average age of the people asserted in the family ontology by the following JessTab rule:
(defrule print_people_total_age
(object (https://wiki.csc.calpoly.edu/OntologyTutorial/family_example.owl#age ?a1))
=>
(bind ?s 0)
(bind ?num 0)
(foreach ?a (create$ ?a1) (+ ?s ?a) (++ ?num) (printout t "Total age " ?s " and average age is " (/ ?s ?num) " of persons" crlf)))
The rule compiles well, but when activated errors this:
Jess reported an error in routine +
while executing (+ ?s ?a)
while executing (foreach ?a (create$ ?a1) (+ ?s ?a) (++ ?num) (printout t "Total age " ?s " and average age is " (/ ?s ?num) " of persons" crlf))
while executing defrule MAIN::print_people_total_ageSSS
while executing (run).
Message: Not a number: "~@http://www.w3.org/2001/XMLSchema#integer 20".
Where am I wrong?