You already have 2 accumulate functions to do what you need:<div><ul><li>collectList</li><li>collectSet</li></ul><div>So, your rule will look like this:</div><div> $countries : HashSet(empty == false) from accumulate (City($name matches "X.*", $country : country), collectSet($country))</div>
<div><br></div><div><br></div><div>Best Regards,</div><br>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br><br>Esteban Aliverti<br>- Developer @ <a href="http://www.plugtree.com" target="_blank">http://www.plugtree.com </a><br>
- Blog @ <a href="http://ilesteban.wordpress.com" target="_blank">http://ilesteban.wordpress.com</a><br>
<br><br><div class="gmail_quote">2011/11/15 Wolfgang Laun <span dir="ltr"><<a href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
This is possible with an accumulate where you code the init/action/result explicily. Perhaps not fully "out of the box" but a box that holds everything would be rather big, wouldn't it? ;-)<br><br>-W<br><br>
<div class="gmail_quote">
2011/11/15 Bruno Freudensprung <span dir="ltr"><<a href="mailto:bruno.freudensprung@temis.com" target="_blank">bruno.freudensprung@temis.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5">
<u></u>
<div text="#000000" bgcolor="#ffffff">
Hi all,<br>
<br>
There is something I can't express using "collect" or "accumulate"
and I would like to have your opinion.<br>
Let's imagine I have the following types :<br>
<br>
<tt> # a country type <br>
<b> declare Country<br>
name : String<br>
end<br>
</b><br>
# a city type holding a reference to its country<br>
<b> declare City<br>
name : String<br>
country : Country<br>
end<br>
</b></tt>
<br>
Let's imagine I have all Country and City objects into the working
memory.<br>
I want to get the set of Countries corresponding to Cities whose
name starts with "X".<br>
<br>
I have the impression that I need a kind of (nonexistent right?)
"collect" syntax that would look like the "accumulate" syntax (a
kind of "anonymous" accumulate function):<br>
<br>
<tt> # meaning I want to collect $country objects and not City
objects<br>
</tt><tt> $countries : HashSet() from collect (City($name matches
"X.*", $country : country)<b>, $country</b>)<br>
</tt><br>
Or a home made accumulate function that builds a set of countries:<br>
<br>
<tt> # custom "buildset" accumulate function<br>
</tt><tt> $countries : HashSet() from accumulate (City($name
matches "X.*", $country : country), <b>buildset</b>($country))<br>
</tt>
<br>
Do you see any other (possibly out of the box) solution?<br>
<br>
Many thanks in advance for your answers,<br>
Best regards,<br><font color="#888888">
<br>
Bruno.<br>
<br>
</font></div>
<br></div></div>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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></blockquote></div><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></blockquote></div><br></div>