Could insert work (from reference):
(insert$ <list-_expression_> <integer-_expression_> <single-or-list-_expression_>+)
Arguments:
- A list, an integer, and one or more lists
- A list
- Returns a new list like the original but with one or more values inserted. Inserts the elements of the second and later lists so that they appear starting at the given 1-based index of the first list.
At 04:32 PM 9/26/2006, you wrote:
Im sure theres a simple and efficient way of doing this, but for some reason Im unable to figure out the solution. On the LHS of my rule, Ive matched a multislot. On the RHS Ive asserted a new fact or list of facts and want to append that to the multislot. Something like the following:
(defrule addFacts
?matchedFact <- (MyTemplate (factList $?facts))
=>
; Initialize the list of new facts to be appended
(bind ?newFacts (create$))
(while (some condition)
; Assert the new fact
(bind ?newFact (assert (Template2 (slot value)))
; Add the new fact to the list of facts to be appended
(bind ?newFacts (create$ ?newFacts ?newFact)))
(modify ?matchedFact (factList create$ (?facts ?newFacts))))
Theres a lot of list creation going on here that seems very wasteful when in fact I really only have one list that I want to keep appending to. I guess within the while loop I could use an ArrayList instead of a Jess list. Would that be more efficient or a better practice in such a case?
Thanks for you help,
- Alan
*
* Ohio University
* Industrial and Manufacturing Systems Engineering Department
* 277 Stocker Center, Athens, OH 45701-2979
* phone: (740) 593-1545
* fax: (740) 593-0778
* e-mail: [EMAIL PROTECTED]
* url: http://www.ent.ohiou.edu/~sormaz
*********************************************************************
