<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
You could use truth maintenance, this won't remove something from a
list, but it will remove a fact from the working memory when a rule is
no longer true.<br>
<br>
Mark<br>
Michael Suzio wrote:
<blockquote
cite="mid:bdb775e20702130841q28a9ba3bk364dc09c6c6ebfbb@mail.gmail.com"
type="cite">Anytime you modify a object, candidate rules are going to
be re-examined. You may need some state variables in addition to this
(to control when rules fire, avoid loops, etc), but the basic rules
could be:<br>
<br>
rule AddVcr
<br>
when<br>
$c: Cart(contents contains "TV", contents excludes "free VCR")<br>
then<br>
$c.add("free VCR");<br>
modify($c);<br>
end<br>
<br>
rule RemoveVcr<br>
when<br>
$c: Cart(contents excludes "TV")
<br>
then<br>
$c.remove("free VCR");<br>
modify($c);<br>
end<br>
<br>
You can fill in the rest. Like I said, you probably need some state
variables so things don't loop, need to exclude the case where a
non-free VCR is legitimately in the cart, etc. But your basic question
should be answered with this approach. Don't think procedurally, think
in terms of a living system when the changes in objects trigger
somewhat asynchronous cascades of matching rules. Calling modify() on
a fact is like restarting the whole matching algorithm for any rules
that had that fact included in their (possible candidate) constraints.
<br>
<br>
<div><span class="gmail_quote">On 2/13/07, <b
class="gmail_sendername">Matt Johnston</b> <<a
moz-do-not-send="true" href="mailto:MJohnston@pubgroup.com">MJohnston@pubgroup.com</a>>
wrote:</span>
<blockquote class="gmail_quote"
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I
am working on rules for an online shopping cart. Depending on the<br>
products in the cart, the customer may get certain discounts.<br>
<br>
If cart contains a TV, add a free VCR.<br>
<br>
I can apply these rules, but what about rolling them back?
<br>
<br>
So in the example above, the rule automatically added a free VCR because<br>
the cart contained a TV. If the customer removes the TV, I need to roll<br>
back the VCR rule and also remove the VCR from the cart.<br>
<br>
Does anyone know how to do this? Is it possible?<br>
<br>
Matt Johnston<br>
Manager of Internet Content<br>
Publishing Group of America<br>
p: 615-468-6053<br>
f: 615-468-6153<br>
<br>
_______________________________________________
<br>
rules-users mailing list<br>
<a moz-do-not-send="true" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a moz-do-not-send="true"
href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users
</a><br>
</blockquote>
</div>
<br>
<pre wrap="">
<hr size="4" width="90%">
_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a>
</pre>
</blockquote>
<br>
</body>
</html>