Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Invert String or Sequence
Invert String or Sequence [message #1608529] Mon, 09 February 2015 15:28 Go to next message
Alexander R is currently offline Alexander RFriend
Messages: 211
Registered: July 2013
Senior Member
Hi,

just a simple question: Is there a build-in function for inverting a string or a sequence in ATL?

~Alex
Re: Invert String or Sequence [message #1608629 is a reply to message #1608529] Mon, 09 February 2015 16:50 Go to previous messageGo to next message
Alexander R is currently offline Alexander RFriend
Messages: 211
Registered: July 2013
Senior Member
Took a while..but here is my solution..

helper def : invert(list:Sequence(String)) : Sequence(String) = 	 
	list->iterate(el; invertedList: Sequence(String) =Sequence{} |
	invertedList.prepend(el)
);


~Alex
Re: Invert String or Sequence [message #1608882 is a reply to message #1608629] Mon, 09 February 2015 20:42 Go to previous message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 350
Registered: September 2012
Location: Belgium
Senior Member

This won't work for regular ATL, but ATL/EMFTVM is based on OCL 2.2 instead of OCL 2.0 and includes the Sequence::reverse() operation. See also http://www.omg.org/spec/OCL/2.2/ for all supported operations (except collectNested()).

Cheers,
Dennis
Previous Topic:problem doing uml association
Next Topic:ATL java Launch not working
Goto Forum:
  


Current Time: Sat Sep 23 05:48:44 GMT 2017

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

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