<br> You should really insert your males and females into your working memory instead of having them as nested lists only. Anyway:<br><br>rule "unlucky male"<br>where<br> $c : City()<br> $m : Male( $age : age ) from $c.maleList<br>
not( Female( age ==$age ) from $c.femaleList )<br>then<br> // $m is unlucky, no female with the same age<br>end<br><br> []s<br> Edson<br> <br><br><div class="gmail_quote">2009/2/2 techy <span dir="ltr"><<a href="mailto:techluver007@gmail.com">techluver007@gmail.com</a>></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>
Hello,<br>
<br>
Please help me to implement following rule in drool. I could not find a way<br>
to iterate two collection using accumulate or collect in LHS.<br>
<br>
public Male{<br>
int age;<br>
//other fields<br>
<br>
}<br>
<br>
public Female{<br>
int age;<br>
//other fields<br>
<br>
}<br>
public City{<br>
<br>
private List<Male> maleList;<br>
private List<Female> femaleList;<br>
<br>
}<br>
<br>
#Rule to get all Male whose age != any of female's<br>
rule "Get Unlucky Male"<br>
when<br>
city : City()<br>
maleList : ArrayList() from collect ( Male( his age = any of<br>
Female's age from city.femaleList ) from city.maleList)<br>
//consequence<br>
end<br>
<font color="#888888">--<br>
View this message in context: <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>
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>
</font></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>