<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
    <title></title>
  </head>
  <body bgcolor="#ffffff" text="#000000">
    On 06/08/2010 16:04, Anstis, Michael (M.) wrote:
    <blockquote
cite="mid:C7774483B6A70C4BB10E917CC1A59DC106CF7196@eu1wam35.warley.ford.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=ISO-8859-1">
      <meta name="Generator" content="MS Exchange Server version
        6.5.7654.12">
      <title>IRC: interesting topic: use of lists using "from" in LHS
        and iterated over in RHS</title>
      <!-- Converted from text/rtf format -->
      <p><font face="Arial" size="2">HI,</font>
      </p>
      <p><font face="Arial" size="2">There was an interesting discussion
          today on IRC; a user "jochen" reported NPEs when trying to
          iterate lists in the RHS constructed in the LHS using "from
          collect".</font></p>
      <p><font face="Arial" size="2">I was wondering how Drools handles
          lists constructed in the LHS; if the list contained 5 elements
          but another rule retracted one of those elements would the
          list available in the RHS contain 4 or 5 elements?</font></p>
      <p><font face="Arial" size="2">Here's a simplification of what was
          posted at </font><a moz-do-not-send="true"
          href="http://pastebin.com/yKGSxFkA"><u><font color="#0000ff"
              face="Arial" size="2">http://pastebin.com/yKGSxFkA</font></u></a>
      </p>
      <p><font face="Arial" size="2">Rule 1</font>
        <br>
        <font face="Arial" size="2">when</font>
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font face="Arial" size="2">$cheese : ArrayList() from
          collect(CheeseFact());</font>
        <br>
        <font face="Arial" size="2">then</font>
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font face="Arial" size="2">for(int i=0;
          i&lt;$cheese.size(); i++) {</font>
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font face="Arial" size="2">//Something useful&#8230;</font>
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font face="Arial" size="2">}</font>
        <br>
        <font face="Arial" size="2">end</font>
      </p>
      <p><font face="Arial" size="2">What if there was another rule that
          did something like this:-</font>
      </p>
      <p><font face="Arial" size="2">Rule 2</font>
        <br>
        <font face="Arial" size="2">When </font>
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font face="Arial" size="2">$cf : CheeseFact(type ==
          "chedder")</font>
        <br>
        <font face="Arial" size="2">Then</font>
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font face="Arial" size="2">retract($cf);</font>
        <br>
        <font face="Arial" size="2">end</font></p>
    </blockquote>
    Each time this "rule 2" fires and retracts a CheeseFact that was in
    $cheese from rule1, the $cheese list will be reduced by one. So
    there should be no null pointers here.<br>
    <br>
    Mark<br>
    <blockquote
cite="mid:C7774483B6A70C4BB10E917CC1A59DC106CF7196@eu1wam35.warley.ford.com"
      type="cite">
      <p>
      </p>
      <p><font face="Arial" size="2">What would be the list Rule 1
          iterates?</font>
      </p>
      <p><font face="Arial" size="2">I'd assume since I believe
          activation execution to be serial it would depend on the
          agenda's conflict resolution strategy or rule salience?</font></p>
      <p><font face="Arial" size="2">What would be the learned opinion?</font>
      </p>
      <p><font color="#000000" face="Arial" size="2">With kind regards,</font>
      </p>
      <p><font color="#000000" face="Arial" size="2">Mike</font>
      </p>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
rules-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-dev">https://lists.jboss.org/mailman/listinfo/rules-dev</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>