<!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.&nbsp; 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>
&nbsp; $c: Cart(contents contains "TV", contents excludes "free VCR")<br>
then<br>
&nbsp;$c.add("free VCR");<br>
&nbsp;modify($c);<br>
end<br>
  <br>
rule RemoveVcr<br>
when<br>
&nbsp;$c: Cart(contents excludes "TV")
  <br>
then<br>
&nbsp;$c.remove("free VCR");<br>
&nbsp;modify($c);<br>
end<br>
  <br>
You can fill in the rest.&nbsp; 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.&nbsp; But your basic question
should be answered with this approach.&nbsp; Don't think procedurally, think
in terms of a living system when the changes in objects trigger
somewhat asynchronous cascades of matching rules.&nbsp; 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> &lt;<a
 moz-do-not-send="true" href="mailto:MJohnston@pubgroup.com">MJohnston@pubgroup.com</a>&gt;
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>