<br>&nbsp;&nbsp; Since Drools language is FOL equivalent, any FOL logic expression can be represented.<br><br>rule &quot;city has unlucky males&quot;<br>&nbsp; where<br>
&nbsp;&nbsp; &nbsp; $c : City()<br>

&nbsp;&nbsp; &nbsp; exists(&nbsp; $m : Male( $age : age ) from $c.maleList and<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; not( Female( age ==$age ) from $c.femaleList ) )<br>&nbsp;
then<br>
&nbsp; &nbsp;&nbsp; // $c has unlucky males<br>&nbsp;
end<br><br>&nbsp;&nbsp; []s<br>&nbsp;&nbsp; Edson<br><br><div class="gmail_quote">2009/2/2 techy <span dir="ltr">&lt;<a href="mailto:techluver007@gmail.com">techluver007@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Thanks Edson.<br>
<br>
Is there way to find City() where if least one unlucky male is found using<br>
current object structure.<br>
<div><div></div><div class="Wj3C7c"><br>
<br>
Edson Tirelli-3 wrote:<br>
&gt;<br>
&gt; &nbsp; &nbsp;You should really insert your males and females into your working<br>
&gt; memory<br>
&gt; instead of having them as nested lists only. Anyway:<br>
&gt;<br>
&gt; rule &quot;unlucky male&quot;<br>
&gt; where<br>
&gt; &nbsp; &nbsp; $c : City()<br>
&gt; &nbsp; &nbsp; $m : Male( $age : age ) from $c.maleList<br>
&gt; &nbsp; &nbsp; not( Female( age ==$age ) from $c.femaleList )<br>
&gt; then<br>
&gt; &nbsp; &nbsp; &nbsp;// $m is unlucky, no female with the same age<br>
&gt; end<br>
&gt;<br>
&gt; &nbsp; &nbsp;[]s<br>
&gt; &nbsp; &nbsp;Edson<br>
&gt;<br>
&gt;<br>
&gt; 2009/2/2 techy &lt;<a href="mailto:techluver007@gmail.com">techluver007@gmail.com</a>&gt;<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; Hello,<br>
&gt;&gt;<br>
&gt;&gt; Please help me to implement following rule in drool. I could not find a<br>
&gt;&gt; way<br>
&gt;&gt; to iterate two collection using accumulate or collect in LHS.<br>
&gt;&gt;<br>
&gt;&gt; public Male{<br>
&gt;&gt; &nbsp;int age;<br>
&gt;&gt; &nbsp;//other fields<br>
&gt;&gt;<br>
&gt;&gt; }<br>
&gt;&gt;<br>
&gt;&gt; public Female{<br>
&gt;&gt; &nbsp;int age;<br>
&gt;&gt; &nbsp;//other fields<br>
&gt;&gt;<br>
&gt;&gt; }<br>
&gt;&gt; public City{<br>
&gt;&gt;<br>
&gt;&gt; &nbsp;private List&lt;Male&gt; &nbsp;maleList;<br>
&gt;&gt; &nbsp;private List&lt;Female&gt; femaleList;<br>
&gt;&gt;<br>
&gt;&gt; }<br>
&gt;&gt;<br>
&gt;&gt; #Rule to get all Male whose age != any of female&#39;s<br>
&gt;&gt; rule &quot;Get Unlucky Male&quot;<br>
&gt;&gt; when<br>
&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp;city : City()<br>
&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp;maleList : ArrayList() from collect ( Male( his age = any of<br>
&gt;&gt; Female&#39;s age &nbsp;from city.femaleList &nbsp;) from city.maleList)<br>
&gt;&gt; //consequence<br>
&gt;&gt; end<br>
&gt;&gt; --<br>
&gt;&gt; View this message in context:<br>
&gt;&gt; <a href="http://www.nabble.com/Iterating-two-collection-in-LHS-tp21796713p21796713.html" target="_blank">http://www.nabble.com/Iterating-two-collection-in-LHS-tp21796713p21796713.html</a><br>
&gt;&gt; Sent from the drools - user mailing list archive at Nabble.com.<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" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; &nbsp;Edson Tirelli<br>
&gt; &nbsp;JBoss Drools Core Development<br>
&gt; &nbsp;JBoss, a division of Red Hat @ <a href="http://www.jboss.com" target="_blank">www.jboss.com</a><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" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br>
&gt;<br>
<br>
--<br>
</div></div>View this message in context: <a href="http://www.nabble.com/Iterating-two-collection-in-LHS-tp21796713p21801175.html" target="_blank">http://www.nabble.com/Iterating-two-collection-in-LHS-tp21796713p21801175.html</a><br>

<div><div></div><div class="Wj3C7c">Sent from the drools - user mailing list archive at Nabble.com.<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" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br> &nbsp;Edson Tirelli<br> &nbsp;JBoss Drools Core Development<br> &nbsp;JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>