Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Xpand] iteration over integer list
[Xpand] iteration over integer list [message #629152] Mon, 27 September 2010 11:23 Go to next message
Stephan Krusche is currently offline Stephan KruscheFriend
Messages: 18
Registered: August 2010
Location: Munich
Junior Member
Hey,

I have an attribute length in my type element which is of type integer. Now I want to generate the following code, where n is the value of length.

callFunction(0);
callFunction(1);
callFunction(2);
callFunction(3);
callFunction(4);
callFunction(5);
...
callFunction(n);

How can i do that? My suggestion was to use a built-in function that generates a List[int] and to iterate over it with FOREACH. But I only know the following operation which only inserts 0 and n into the list:

«FOREACH {'0', element.length} AS i»
callFunction(«i»);
«ENDFOREACH»


Is there also a mechanism to insert all values between 0 and n into that list? (e.g. like in python the following code "for i in range(0, n):")

Thanks!
Re: [Xpand] iteration over integer list [message #629309 is a reply to message #629152] Mon, 27 September 2010 18:35 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hello Stephan,

yes this is possible

«FOREACH 0.upTo(10) AS i»
callFunction(«i»);
«ENDFOREACH»


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:[Announce] Demonstrations at ESE's Modeling Symposium
Next Topic:XPand template not working after upgrading to Helios
Goto Forum:
  


Current Time: Sat Apr 20 01:44:01 GMT 2024

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

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

Back to the top