On Feb 20, 2008, at 9:15 AM, Henrique Lopes Cardoso wrote:

There is a small bug in the 'actually-remove-things-from-c' rule:
(remove ?c ?b?) should be (remove ?c ?x)


Thanks, yes.

Anyway, is 'do-something-when-something-gets-removed-from-c'
guaranteed
to fire? If 'actually-remove-things-from-c' fires before, then
'do-something-when-something-gets-removed-from-c' will not fire, since
?c was already modified!

Indeed. Probably should be more like

(defrule do-something-when-something-gets-removed-from-c
    "This is the rule you were asking about how to write"
    ?c <- (C)
    (remove ?c ?x)
    =>
    (do whatever you want to do here))



Henrique


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:owner-jess-
[EMAIL PROTECTED]
On Behalf Of Ernest Friedman-Hill
Sent: woensdag 20 februari 2008 13:31
To: jess-users
Subject: Re: JESS: Rules for detecting changes of a multislot

Lars,

...

(defrule remove-something-from-c
    ?c <- (C (m ?a ?b ?c))
    =>
    (modify ?c (m ?a ?c)))

You'd say something like

(defrule want-to-remove-something-from-c
    ?c <- (C (m ?a ?b ?c))
    =>
    ;; Instead of modifying ?c, issue a command to do so
    (assert (remove ?c ?b)))

(defrule actually-remove-things-from-c
    "Process commands to remove items from multislot m of C facts"
    (declare (no-loop TRUE))
    ?c <- (C (m $?first ?x $?rest))
    (remove ?c ?b)
    =>
    (modify ?c (m $?first $?rest)))

(defrule do-something-when-something-gets-removed-from-c
    "This is the rule you were asking about how to write"
    ?c <- (C (m $?first ?x $?last))
    (remove ?c ?x)
    =>
    (do whatever you want to do here))

(defrule clean-up-remove-commands
    "A low salience rule to clean up remove commands when you're
done
with them."
    (declare (salience -1))
    ?r <- (remove ? ?)
    =>
    (retract ?r))

...

--------------------------------------------------------------------
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 owner-jess-
[EMAIL PROTECTED]
--------------------------------------------------------------------

---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences          Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
PO Box 969, MS 9012                 [EMAIL PROTECTED]
Livermore, CA 94550                 http://www.jessrules.com

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