<!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">
inside of a pattern == is in equality. Inside of an eval it all depends
if you are using the java or mvel dialect - its just an expression, so
it obeys the host expression language.<br>
<br>
Mark<br>
Aaron Dixon wrote:
<blockquote
 cite="mid:5b1018900708070706g53953060rbfedb778efd20425@mail.gmail.com"
 type="cite">The "from" conditional element solves part of my problem:<br>
  <br>
rule "Find matching entry in parallel arrays (alternate)"<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 ( " Found match at index ? : " + $fi + "!" );<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 moz-do-not-send="true"
 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'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 == "ManU" )<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() + " likes Manchester" );<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 == "Chelsea" )<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() + " does not like Chelsea
at<br>
all" );<br>
&nbsp;&nbsp;&nbsp;&nbsp;end<br>
    <br>
    <br>
    <br>
Mark Proctor wrote:<br>
&gt;<br>
&gt; We don'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; 'from' allows iteration of lists, so you could potentially do it
this<br>
&gt; way, although it doesn'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'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 "Find matching entry in parallel arrays"<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 ( "Found match at index " + $i +
"!" );
    <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'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'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 moz-do-not-send="true"
 href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt;&gt; <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>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; rules-users mailing list<br>
&gt; <a moz-do-not-send="true"
 href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt; <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>
&gt;<br>
&gt;<br>
    <br>
--<br>
View this message in context: <a moz-do-not-send="true"
 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
 moz-do-not-send="true" href="http://Nabble.com">Nabble.com</a>.<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>