Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Why returning a sequence of a sequence ?
[ATL] Why returning a sequence of a sequence ? [message #57021] Thu, 09 August 2007 14:47 Go to next message
Guillaume Gauffre is currently offline Guillaume GauffreFriend
Messages: 65
Registered: July 2009
Member
Hi,

considering these 3 operations on the Set 'totargets' :

totargets.debug('relFromS');
totargets->collect(e|e.target).debug('AOut');
totargets->collect(e|e.target)->collect(e|e.relationShipSources).debug('relToR');

the two first operations print well a sequence for each, but the third
prints a sequence of a sequence 'Sequence {Sequence {IN!<unnamed>,
IN!<unnamed>, IN!<unnamed>}}'. Why this behaviour ?
I must use the operation flatten() to finally get my sequence !

Thanks

Guillaume
Re: [ATL] Why returning a sequence of a sequence ? [message #57074 is a reply to message #57021] Thu, 09 August 2007 15:51 Go to previous messageGo to next message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hi,

> considering these 3 operations on the Set 'totargets' :
>
> totargets.debug('relFromS');
> totargets->collect(e|e.target).debug('AOut');
>
totargets->collect(e|e.target)->collect(e|e.relationShipSources).debug('relToR');

>
>
> the two first operations print well a sequence for each, but the third
> prints a sequence of a sequence 'Sequence {Sequence {IN!<unnamed>,
> IN!<unnamed>, IN!<unnamed>}}'. Why this behaviour ?

Sometimes you want to get a Sequence of Sequence.


> I must use the operation flatten() to finally get my sequence !

Yes.


Of course, we could have the "collectNested" iterator that would return
a Sequence of Sequence. The collect iterator would then consist of
"collectNested" followed by a call to "flatten".

However, switching for this alternate behavior would break some existing
transformations relying on the way it currently works.


Regards,

Frédéric Jouault
Re: [ATL] Why returning a sequence of a sequence ? [message #57100 is a reply to message #57074] Thu, 09 August 2007 15:58 Go to previous message
Guillaume Gauffre is currently offline Guillaume GauffreFriend
Messages: 65
Registered: July 2009
Member
Ok, fine !

Thank you for your rapid response

Guillaume


Frédéric Jouault a écrit :
> Hi,
>
> > considering these 3 operations on the Set 'totargets' :
> >
> > totargets.debug('relFromS');
> > totargets->collect(e|e.target).debug('AOut');
> >
> totargets->collect(e|e.target)->collect(e|e.relationShipSources).debug('relToR');
>
> >
> >
> > the two first operations print well a sequence for each, but the third
> > prints a sequence of a sequence 'Sequence {Sequence {IN!<unnamed>,
> > IN!<unnamed>, IN!<unnamed>}}'. Why this behaviour ?
>
> Sometimes you want to get a Sequence of Sequence.
>
>
> > I must use the operation flatten() to finally get my sequence !
>
> Yes.
>
>
> Of course, we could have the "collectNested" iterator that would return
> a Sequence of Sequence. The collect iterator would then consist of
> "collectNested" followed by a call to "flatten".
>
> However, switching for this alternate behavior would break some existing
> transformations relying on the way it currently works.
>
>
> Regards,
>
> Frédéric Jouault
Previous Topic:[ATL] Empty stack Exception
Next Topic:[ATL] KM3 metamodel extension
Goto Forum:
  


Current Time: Thu Jan 21 13:44:26 GMT 2021

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

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

Back to the top