The &quot;from&quot; conditional element solves part of my problem:<br><br>rule &quot;Find matching entry in parallel arrays (alternate)&quot;<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; $fi : Object() from $first<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $si : Object() from $second<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; eval( $fi == $si )<br>&nbsp;&nbsp;&nbsp; then<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println ( &quot; Found match at index ? : &quot; + $fi + &quot;!&quot; );<br>end
<br><br>I do want reference equality (==) in my eval. But I understand that object equality would look just like:<br><br>eval( $fi .equals( $si ) )<br><br><br>Thanks!<br><br>Aaron<br><br><br><div><span class="gmail_quote">
On 8/7/07, <b class="gmail_sendername">Mike D</b> &lt;<a href="mailto:mike.dalaker@kewill.com">mike.dalaker@kewill.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;">
<br>Mark,<br><br>Just to be sure I read this correctly:<br><br>eval( $fi == $si )<br><br>means it&#39;s checking objects, not values within the object?<br>If a compare of values is needed, another eval would have to be written to
<br>compare temp value.<br><br>Thanks,<br>Mike<br><br><br>Oh, and can we change the documenatation examples please?<br><br>Somthing like...<br><br>rule<br>&nbsp;&nbsp;&nbsp;&nbsp;when<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Team( $team : name == &quot;ManU&quot; )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$person : Person( favouriteTeam == $team )
<br>&nbsp;&nbsp;&nbsp;&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println( $person.getName() + &quot; likes Manchester&quot; );<br>&nbsp;&nbsp;&nbsp;&nbsp;end<br><br>rule<br>&nbsp;&nbsp;&nbsp;&nbsp;when<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Team( $team : name == &quot;Chelsea&quot; )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$person : Person( favouriteTeam != $team )
<br>&nbsp;&nbsp;&nbsp;&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println( $person.getName() + &quot; does not like Chelsea at<br>all&quot; );<br>&nbsp;&nbsp;&nbsp;&nbsp;end<br><br><br><br>Mark Proctor wrote:<br>&gt;<br>&gt; We don&#39;t really recommend you assert ArrayLists etc as facts, as they
<br>&gt; have no contextual meaning<br>&gt;<br>&gt; $first : ArrayList( )<br>&gt; $second : ArrayList( this != $first )<br>&gt; $fi Object() from $first<br>&gt; $si Object from $second<br>&gt; eval( $fi == $si )<br>&gt;<br>
&gt; &#39;from&#39; allows iteration of lists, so you could potentially do it this<br>&gt; way, although it doesn&#39;t provide an index number for you.... You could<br>&gt; possibly have a global that as part of a function in eval get
<br>&gt; incremented and that global is available in the consequence. But you&#39;ll<br>&gt; have to be very careful with concurrency.... Might be easier to have a<br>&gt; hashmap of indexes where the key is made up of $first and $second. Btw
<br>&gt; == checks for same instances, not an equality check, is that what you<br>&gt; wanted?<br>&gt;<br>&gt; Mark<br>&gt;<br>&gt; Aaron Dixon wrote:<br>&gt;&gt; My problem boils down to finding matching entries in parallel arrays.
<br>&gt;&gt;<br>&gt;&gt; Here is a rule that succesfully does just that:<br>&gt;&gt;<br>&gt;&gt; rule &quot;Find matching entry in parallel arrays&quot;<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; when<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $first : ArrayList( )<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $second : ArrayList( this != $first )
<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $i : Integer( this &lt; $first.size )<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; eval( $first.get($i) == $second.get($i) )<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; then<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println ( &quot;Found match at index &quot; + $i + &quot;!&quot; );
<br>&gt;&gt; end<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt; To execute this rule, I must insert (assert) the two ArrayList facts<br>&gt;&gt; as well as at least as many Integer facts as there are items in the<br>&gt;&gt; ArrayLists.
<br>&gt;&gt;<br>&gt;&gt; What I don&#39;t like about this rule is that<br>&gt;&gt;<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; (1) I have to assert the Integers<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; (2) I can&#39;t support arbitrarily-sized lists in my rules (without<br>
&gt;&gt; asserting that many Integer facts)<br>&gt;&gt;<br>&gt;&gt; So -- Is there a better way?<br>&gt;&gt;<br>&gt;&gt; What if a future version of Drools supported implicit Number facts<br>&gt;&gt; that allowed for these kinds of indexing rules?
<br>&gt;&gt;<br>&gt;&gt; Aaron<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt; ------------------------------------------------------------------------<br>&gt;&gt;<br>&gt;&gt; _______________________________________________
<br>&gt;&gt; rules-users mailing list<br>&gt;&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users
</a><br>&gt;&gt;<br>&gt;<br>&gt;<br>&gt; _______________________________________________<br>&gt; rules-users mailing list<br>&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users">
https://lists.jboss.org/mailman/listinfo/rules-users</a><br>&gt;<br>&gt;<br><br>--<br>View this message in context: <a href="http://www.nabble.com/finding-matching-entries-in-parallel-arrays-tf4225120.html#a12034578">http://www.nabble.com/finding-matching-entries-in-parallel-arrays-tf4225120.html#a12034578
</a><br>Sent from the drools - user mailing list archive at <a href="http://Nabble.com">Nabble.com</a>.<br><br>_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org">
rules-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br></blockquote></div><br>