Maybe I&#39;m missing something but couldn&#39;t you simply create checkGroups as a Set&lt;String&gt;and just compare its size() to $fact.Groups.size() ?<br><br><br>rule check<br>    when<br>        $fact : StrColl( $gr : groups, eval( $gr.size() != (new HashSet( $gr )).size() ) )<br>
    then<br>        System.out.println( &quot;failed&quot; );<br>end<br><br>-W<br><br><div class="gmail_quote">On Fri, Apr 17, 2009 at 8:22 AM, campbeln <span dir="ltr">&lt;<a href="mailto:nicholas.campbell@arc.gov.au">nicholas.campbell@arc.gov.au</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
I have an ArrayList of strings that I need to ensure are all internally<br>
unique (ie: {&quot;1&quot;,&quot;2&quot;,&quot;3&quot;} = OK, {&quot;1&quot;,&quot;2&quot;,&quot;1&quot;} = Error). I&#39;ve managed to<br>
cobble together the code below but I&#39;m running into the &quot;forall w/ an<br>
internal from&quot; issue. I don&#39;t believe an upgrade is feasible at the moment,<br>
so are there any alternative solutions?<br>
<br>
NOTE: The collection of both $factGroups and $checkGroups is almost<br>
definitely redundant, so please keep any laughing to a minimum =)<br>
<br>
<br>
rule &quot;BR033&quot;<br>
   no-loop true<br>
     when<br>
                $fact : MyFact()<br>
<br>
                //# Get 2 copies of all the Groups associated with the $fact<br>
                $factGroups : ArrayList() from collect (<br>
                        Group() from $fact.Groups<br>
                )<br>
                $checkGroups : ArrayList() from collect (<br>
                        Group() from $fact.Groups<br>
                )<br>
<br>
                //# Traverse the $factGroups comparing each $currentGroup to the list<br>
                //# within $checkGroups, erroring out if something other then 1 is found<br>
                forall (<br>
                        $currentGroup : Group(this memberOf $factGroups)<br>
                        $test : ArrayList(size != 1) from collect(<br>
                                Group(this == $currentGroup) from $checkGroups<br>
                        )<br>
                )<br>
    then<br>
        System.out.println(&quot;Failed: BR033&quot;);<br>
    end<br>
<br>
I have found a number of postings that seem to be related, namely<br>
<a href="http://www.nabble.com/Best-practice-for-rules-against-multiple-objects-td5621720.html#a5621720" target="_blank">http://www.nabble.com/Best-practice-for-rules-against-multiple-objects-td5621720.html#a5621720</a><br>

but I&#39;ve been unable to cobble together a solution thus far. All help is<br>
appreciated!<br>
<br>
Thanks!<br>
<font color="#888888">--<br>
View this message in context: <a href="http://www.nabble.com/Ensure-all-values-in-a-list-are-unique--tp23071079p23071079.html" target="_blank">http://www.nabble.com/Ensure-all-values-in-a-list-are-unique--tp23071079p23071079.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>