Hello,
I am trying to update a multislot with a rule. The problem is that the
rule enters into an infinite loop. My example is as follows:
- I have Books and Authors,
- a Book has one or many Authors,
- an Author has one or many books.
Book facts are defined including the author list, but Author facts are
defined without the book list. So I wrote a rule for updating the books
of the authors. However, the “modify” causes an infinite loop.
This is the code of my example:
(deftemplate Book
(slot title)
(multislot authors)
)
(deftemplate Author
(slot name)
(multislot books)
)
(deffacts books_samples
(Book (title "Jess in Action") (authors "Ernest Friedman-Hill"))
(Book (title "The Unified Software Development Process") (authors "Ivar
Jacobson" "Grady Booch" "James Rumbaugh"))
(Book (title "Unified Modeling Language User Guide") (authors "Grady
Booch" "James Rumbaugh" "Ivar Jacobson" ))
(Author (name "Ernest Friedman-Hill"))
(Author (name "Grady Booch"))
(Author (name "James Rumbaugh"))
(Author (name "Ivar Jacobson"))
)
(defrule updateAuthorBookList
?Author <- (Author (name ?name) (books $?books))
(Book (title ?title) (authors $?authors&:(member$ ?name $?authors)))
=>
(modify ?Author (books (create$ $?books ?title)))
(printout t ?name " is the author of the book: " ?title crlf)
)
(reset)
(run)
When I delete the “modify” line, the rule prints the results well.
Any suggestion?
Thank you in advance,
Joaquín
--------------------------------------------------------------------
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]
--------------------------------------------------------------------