You should really insert your males and females into your working memory instead of having them as nested lists only. Anyway:

rule "unlucky male"
where
    $c : City()
    $m : Male( $age : age ) from $c.maleList
    not( Female( age ==$age ) from $c.femaleList )
then
     // $m is unlucky, no female with the same age
end

   []s
   Edson
   

2009/2/2 techy <techluver007@gmail.com>

Hello,

Please help me to implement following rule in drool. I could not find a way
to iterate two collection using accumulate or collect in LHS.

public Male{
 int age;
 //other fields

}

public Female{
 int age;
 //other fields

}
public City{

 private List<Male>  maleList;
 private List<Female> femaleList;

}

#Rule to get all Male whose age != any of female's
rule "Get Unlucky Male"
when
       city : City()
       maleList : ArrayList() from collect ( Male( his age = any of
Female's age  from city.femaleList  ) from city.maleList)
//consequence
end
--
View this message in context: http://www.nabble.com/Iterating-two-collection-in-LHS-tp21796713p21796713.html
Sent from the drools - user mailing list archive at Nabble.com.

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users



--
 Edson Tirelli
 JBoss Drools Core Development
 JBoss, a division of Red Hat @ www.jboss.com