Home » Archived » M2M (model-to-model transformation) » [ATL] Iterating over collections
[ATL] Iterating over collections [message #730603] |
Wed, 28 September 2011 17:06 |
nicgue Messages: 2 Registered: September 2011 |
Junior Member |
|
|
Hi,
i got two sequences: a = Sequence {0,2,3,6}, b = Sequence {2,1,2,1}.
Now i want to create the following string: '(0,2)(2,1)(3,2)(6,1)', similar to the zip function in functional programming. I tried lots of approaches, which didn't work. So, how is this possible without the possibility to iterate over multiple sequences with an iteration counter?
Thank you,
nicgue
[Updated on: Wed, 28 September 2011 17:06] Report message to a moderator
|
|
| | |
Re: [ATL] Iterating over collections [message #730651 is a reply to message #730619] |
Wed, 28 September 2011 19:05 |
Ed Willink Messages: 7680 Registered: July 2009 |
Senior Member |
|
|
Hi
Or you can create one
let a : Sequence(Integer) = Sequence{0,2,3,6} in
let b : Sequence(Integer) = Sequence{2,1,2,1} in
Sequence{1..a->size()}->collectNested(e : Integer |
Sequence{a->at(e),b->at(e)})
Regards
Ed Willink
On 28/09/2011 18:54, Sylvain EVEILLARD wrote:
> You do have an iteration counter : the size of the result.
> let a : OclAny = Sequence{0,2,3,6} in
> let b : OclAny = Sequence{2,1,2,1} in
> a->iterate(e; res : OclAny = Sequence{}|
> res.append(Sequence{e,b->at(res.size() + 1)})
> )
|
|
|
Goto Forum:
Current Time: Thu Dec 12 22:50:49 GMT 2024
Powered by FUDForum. Page generated in 0.03551 seconds
|