Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » how to concatenate each element of first sequence with every other element of the second sequence
how to concatenate each element of first sequence with every other element of the second sequence [message #917558] Thu, 20 September 2012 07:43 Go to next message
noi poi is currently offline noi poiFriend
Messages: 29
Registered: June 2012
Junior Member
hey there.

i am using ATL and i have done the following

helper def : sequenceofcomp : Sequence(String)= Sequence {'oven','powertube'};
helper def : sequenceofbehavior : Sequence(String) = Sequence {'open', 'off'};

helper def : first: Sequence(String) = thisModule.sequenceofcomp ->
collect(c|c.concat(thisModule.sequenceofbehavior -> collect(b|b) ) ) -> iterate(s; seq:Sequence(String) =
Sequence{}| seq.append(s));

the output of this is oven[open,off] and powertube[open,off].
What i want is that oven gets concatenated with open and off and powertube gets concatenated with open and off in a sequence

how can i achieve this

Thanks in advance
Re: how to concatenate each element of first sequence with every other element of the second sequenc [message #917683 is a reply to message #917558] Thu, 20 September 2012 10:18 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4188
Registered: July 2009
Senior Member
Hi

Once you express your desire as an algorithm, you should be able to
express it in OCL.

So try re-expressing, avoiding non-algorithmic English such as

"oven gets concatenated with open"

Why 'oven', why 'open' ?

Once you answer these questions as an iteration your problem is solved.

Hint: Sequence{1..x->size()} is a convenient way of constructing a loop
variable over x.

Regards

Ed Willink

On 20/09/2012 08:43, noi poi wrote:
> hey there.
> i am using ATL and i have done the following
>
> helper def : sequenceofcomp : Sequence(String)= Sequence
> {'oven','powertube'};
> helper def : sequenceofbehavior : Sequence(String) = Sequence {'open',
> 'off'};
>
> helper def : first: Sequence(String) = thisModule.sequenceofcomp ->
> collect(c|c.concat(thisModule.sequenceofbehavior -> collect(b|b) )
> ) -> iterate(s; seq:Sequence(String) =
> Sequence{}| seq.append(s));
>
> the output of this is oven[open,off] and powertube[open,off]. What i
> want is that oven gets concatenated with open and off and powertube
> gets concatenated with open and off in a sequence
> how can i achieve this
>
> Thanks in advance
Previous Topic:[Announce] Eclipse OCL 4.0.1 (Juno SR1) RC4 is now available
Next Topic:Extend EcoreEnvironment locally
Goto Forum:
  


Current Time: Mon Dec 22 10:04:07 GMT 2014

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

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