Hi,
Thanks a lot for your quick aid.
I have a little bit modified this base in order to perform the operation for n assertions and to print the final sum:
firstcode---------------------------------------------------------
(deftemplate number (slot name)(slot value (default 0)))
(defrule add-n-values
?n1<-(number(value ?v1))
?n2<-(number(value ?v2 &
< ?n1 ?n2)))
=>
(retract ?n1 ?n2)
(assert(number (value (+ ?v1 ?v2))))
)
(defrule print-solution
(number(value ?v))
=>
(printout t "the sum is " ?v crlf))
(assert(number(name x)(value 1)))
(assert(number(name y)(value 3)))
(assert(number(name z)(value 1)))
(assert (number (name useless))); useless assertion to start operation
(run)
------------------------------------------------------------
I think this code is correct (at least for me, because it runs as i want), but i don't know why, when i put the printout in the the first rule (add-n-value):
second code-------------------------------------------------
(deftemplate number (slot name)(slot value (default 0)))
(defrule add-n-values
?n1<-(number(value ?v1))
?n2<-(number(value ?v2 &
< ?n1 ?n2)))
=>
(retract ?n1 ?n2)
(assert(number (value (+ ?v1 ?v2))))
(printout t "the sum is " (+ ?v1 ?v2) crlf)
)
(assert(number(name x)(value 1)))
(assert(number(name y)(value 3)))
(assert(number(name z)(value 1)))
(assert (number (name useless))); useless assertion to start operation
(run)
------------------------------------------------------------------
i get 1,4,5 on my console (for me it is logic) and when i perform the printout in another rule (first code)i get the final result (for me, i should obtain the same result on my console). The last assertion allows to fire the rule when only one value is asserted.
Thanks again!!
Nicolas