I think Noah Zimmerman wrote:
> I would like to make a copy of a fact, such that I can retract the
> original and be left with my duplicate.  Naturally, I have tried the
> duplicate function, however this requires three arguments, the third of
> which must be a list with "the name of a slot in this fact and a new
> value to assign to the slot."  This argument must be supplied, but I do
> not wish to change any of the values in the slot.  I could always get
> the current value of the original slot and copy that to the duplicate
> but that seems like extra work.  What is the proper way to do this? 
> Thanks!


Hmm. Would be easier to answer if I knew what you wanted to accomplish
by doing this; but anyway: from Java, you could use "clone()." on the
Fact object, and actually you could do this from Jess too,

(defrule clone-activating-fact
  ?f1 <- (my-fact a b c)
  =>
  (bind ?f2 (?f1 clone))
  ???)

Now, I wrote ??? because I'm not sure what you want to do with that
fact ?f2. If you assert it, you'll get FALSE back, as since it's an exact
duplicate of an existing fact, it can't go in the fact list. If you
retract ?f1 and then assert ?f2, then the rule will be reactivated and
you'll have an infinite loop.


---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
PO Box 969, MS 9012                 [EMAIL PROTECTED]
Livermore, CA 94550         http://herzberg.ca.sandia.gov

--------------------------------------------------------------------
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]
--------------------------------------------------------------------

Reply via email to