<!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">
We don't really recommend you assert ArrayLists etc as facts, as they
have no contextual meaning<br>
<br>
$first : ArrayList( )
<br>
$second : ArrayList( this != $first )<br>
$fi Object() from $first<br>
$si Object from $second<br>
eval( $fi == $si )<br>
<br>
'from' allows iteration of lists, so you could potentially do it this
way, although it doesn't provide an index number for you.... You could
possibly have a global that as part of a function in eval get
incremented and that global is available in the consequence. But you'll
have to be very careful with concurrency.... Might be easier to have a
hashmap of indexes where the key is made up of $first and $second. Btw
== checks for same instances, not an equality check, is that what you
wanted?<br>
<br>
Mark<br>
<br>
Aaron Dixon wrote:
<blockquote
 cite="mid:5b1018900708060903k1ee87fd2pc01abfd4a51dfe45@mail.gmail.com"
 type="cite">My problem boils down to finding matching entries in
parallel arrays.<br>
  <br>
Here is a rule that succesfully does just that:<br>
  <br>
rule "Find matching entry in parallel arrays"<br>
&nbsp;&nbsp;&nbsp; when<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $first : ArrayList( )
  <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $second : ArrayList( this != $first )<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $i : Integer( this &lt; $first.size )<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; eval( $first.get($i) == $second.get($i) )<br>
&nbsp;&nbsp;&nbsp; then<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println ( "Found match at index " + $i + "!" );
  <br>
end<br>
  <br>
  <br>
To execute this rule, I must insert (assert) the two ArrayList facts as
well as at least as many Integer facts as there are items in the
ArrayLists.<br>
  <br>
What I don't like about this rule is that<br>
  <br>
&nbsp;&nbsp;&nbsp; (1) I have to assert the Integers<br>
&nbsp;&nbsp;&nbsp; (2) I can't support arbitrarily-sized lists in my rules (without
asserting that many Integer facts)<br>
  <br>
So -- Is there a better way? <br>
  <br>
What if a future version of Drools supported implicit Number facts that
allowed for these kinds of indexing rules?
  <br>
  <br>
Aaron<br>
  <br>
  <br>
  <br>
  <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>