Hi, this simple example show a problem I still have when designing Jess 
rules.What I should do to avoid this situation in which two instances of Y will 
be created.
 
If what I try to do is not clear, please say so.
Thanks.
 
CLP file :
 
(deftemplate X (slot a))
 
(deftemplate Y   (slot s))
 
(defrule sum-X    ?x1 <- (X (a ?a1))    ?x2 <- (X (a ?a2))    (not (test (eq 
?x1 ?x2)))=>    (assert (Y (s (+ ?a1 ?a2))))    (printout t "y asserted " ?a1 " 
" ?a2 crlf))
 
(reset)
 
(assert (X (a 3)))(assert (X (a 5)))
 
(run)
 
Result :
 
Jess, the Rule Engine for the Java Platform
Copyright (C) 2006 Sandia Corporation
Jess Version 7.0p1 12/21/2006
 

y asserted 5 3
y asserted 3 5
_________________________________________________________________
Soyez parmi les premiers à essayer Windows Live Mail.
http://ideas.live.com/programpage.aspx?versionId=5d21c51a-b161-4314-9b0e-4911fb2b2e6d

Reply via email to