<!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> # 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>
<br>
Bruno.<br>
<br>
</body>
</html>