how to concatenate each element of first sequence with every other element of the second sequence [message #917558] |
Thu, 20 September 2012 03:43  |
Eclipse User |
|
|
|
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 06:18  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.23387 seconds