Thanks for the advice. I studied this code before. With uncommeting
engine.run(10) it works well. At this point I'd like to suggest a small
change in syntax. I added a new variable to defquery. By declaring
variable rule-activation to a number, it fires the given number of
activations, if the value is <all>, it fires all activations (what can
lead to infinite branches), setting value to <no> (or zero) running
defqueries works as it works now, this is the default setting.
So the defquery looks now like this:
(defquery rec-factorial
(declare
(variables ?x)
(rule-activation all))
(factorial ?x ?r)
)
With commented engine.run(10) the recursive calling of a query works if
the rule for counting the factorial is this:
(defrule do-factorial
(need-factorial ?x&:(> ?x 1) ?)
=>
(assert (need-factorial (- ?x 1) nil))
(printout t ">>before run:: " ?x crlf)
(call (engine) run)
(printout t ">>after run:: " ?x crlf)
(bind ?res (run-query rec-factorial (- ?x 1)))
(bind ?token (call ?res next))
(bind ?fact (call ?token topFact))
(bind ?slot (fact-slot-value ?fact __data))
(bind ?r (nth$ 2 ?slot))
(assert (factorial ?x (* ?x ?r)))
)
But I don't like it this way. Do you like the idea of declaring the
number of rules to be fired in the header of the query?
Gyuri
--------------------------------------------------------------------
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]
--------------------------------------------------------------------