Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Interleave and union two collections
[ATL] Interleave and union two collections [message #12006] Mon, 22 January 2007 14:38 Go to next message
Ronan is currently offline RonanFriend
Messages: 10
Registered: July 2009
Junior Member
Hi,
I have two ordered sets A and B. I would like to interleave (i.e. mix
alternately) their contents so the union set would have an element of A,
then an element of B and so on.... Ideally I would like to do this
declaritevely, as doing it imperatively is very long and messy i.e. Using
a do{} at the end of the rule.

The following code is used to union the two sets A and B, which I have
sorted by an order property.

union_collection <-
MMa!A.allInstances()->sortedBy(e|e.order)->union(MMa!B.allInstances()- >sortedBy(e|e.eContainer().order))

I was thinking if I could capture the e.order value from the first A sort
as a variable, I could then use this value to influence the "at" position
in the second B sort. This hasn't worked as of yet.

Any ideas?

Thanks,
Ronan
Re: [ATL] Interleave and union two collections [message #12165 is a reply to message #12006] Thu, 25 January 2007 11:25 Go to previous message
Ronan is currently offline RonanFriend
Messages: 10
Registered: July 2009
Junior Member
I couldn't come up with a solution so I went the imperative way. In case
other people have this issue the following pseudocode is based on my
solution. It should be at the bottom of a matching rule...


do
{
--interleave A and B based on their order
for(a in a_holder->sortedBy(e|e.order))
{
unionset <- thisModule.OperationA(a);
for(b in b_holder->sortedBy(e|e.eContainer().order))
{
unionset <- thisModule.OperationB(b);
}
}
}

Cheers,
Ronan
Previous Topic:xTend and code generation
Next Topic:Problems with appling Stereotypes to UML2 elements #1905 at yahooList
Goto Forum:
  


Current Time: Fri Mar 29 12:16:13 GMT 2024

Powered by FUDForum. Page generated in 0.03801 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top