<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body 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>&nbsp;&nbsp;&nbsp; # a country type <br>
      <b>&nbsp;&nbsp;&nbsp; declare Country<br>
        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; name : String<br>
        &nbsp;&nbsp;&nbsp; end<br>
      </b><br>
      &nbsp;&nbsp;&nbsp; # a city type holding a reference to its country<br>
      <b>&nbsp;&nbsp;&nbsp; declare City<br>
        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; name : String<br>
        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; country : Country<br>
        &nbsp;&nbsp;&nbsp; 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>&nbsp;&nbsp;&nbsp; # meaning I want to collect $country objects and not City
      objects<br>
    </tt><tt>&nbsp;&nbsp;&nbsp; $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>&nbsp;&nbsp;&nbsp; # custom "buildset" accumulate function<br>
    </tt><tt>&nbsp;&nbsp;&nbsp; $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>
    <br>
    Bruno.<br>
    <br>
  </body>
</html>