<br> Since Drools language is FOL equivalent, any FOL logic expression can be represented.<br><br>rule "city has unlucky males"<br> where<br>
$c : City()<br>
exists( $m : Male( $age : age ) from $c.maleList and<br>
not( Female( age ==$age ) from $c.femaleList ) )<br>
then<br>
// $c has unlucky males<br>
end<br><br> []s<br> Edson<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>
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>
><br>
> You should really insert your males and females into your working<br>
> memory<br>
> 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>
> 2009/2/2 techy <<a href="mailto:techluver007@gmail.com">techluver007@gmail.com</a>><br>
><br>
>><br>
>> Hello,<br>
>><br>
>> Please help me to implement following rule in drool. I could not find a<br>
>> 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>
>> --<br>
>> View this message in context:<br>
>> <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>
>><br>
><br>
><br>
><br>
> --<br>
> Edson Tirelli<br>
> JBoss Drools Core Development<br>
> JBoss, a division of Red Hat @ <a href="http://www.jboss.com" target="_blank">www.jboss.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" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
><br>
><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> 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>