Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Flatten Sequence(String) to String
Flatten Sequence(String) to String [message #1663937] Tue, 10 March 2015 17:15 Go to next message
Robbie Simpson is currently offline Robbie SimpsonFriend
Messages: 7
Registered: February 2015
Junior Member
Hi folks,

I currently have an Acceleo expression that evaluates to a Sequence(String). In my case, this expression is a list of dependencies, so I want to end up with a compound string that looks something like : "Relies on: [Dependency, Dependency]. My problem is that the logical way to do this seems to be by concat - but something like concat("Relies on", mylongexpression) throws a type error, as one element is a String and the other is
a Sequence(String).

Could you advise a solution to this? Is there someway of flattening a Sequence(String) down to an individual String, or a better way of combining the two?

Cheers,
Robbie
Re: Flatten Sequence(String) to String [message #1664055 is a reply to message #1663937] Tue, 10 March 2015 18:16 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5834
Registered: July 2009
Senior Member
Hi

Today you need to use iterate something like:

let aList : Sequence(String) ... in 'Relies on: [' +
aList->iterate(s; acc : String = '' | if acc = '' then acc + s else acc
+ ', ' + s endif) +']'

Regards

Ed Willink


On 10/03/2015 17:15, Robbie Simpson wrote:
> Hi folks,
>
> I currently have an Acceleo expression that evaluates to a
> Sequence(String). In my case, this expression is a list of
> dependencies, so I want to end up with a compound string that looks
> something like : "Relies on: [Dependency, Dependency]. My problem is
> that the logical way to do this seems to be by concat - but something
> like concat("Relies on", mylongexpression) throws a type error, as one
> element is a String and the other is
> a Sequence(String).
>
> Could you advise a solution to this? Is there someway of flattening a
> Sequence(String) down to an individual String, or a better way of
> combining the two?
>
> Cheers,
> Robbie
Re: Flatten Sequence(String) to String [message #1666027 is a reply to message #1664055] Wed, 11 March 2015 14:04 Go to previous message
Robbie Simpson is currently offline Robbie SimpsonFriend
Messages: 7
Registered: February 2015
Junior Member
Thanks - it's not pretty, but it certainly works.
Previous Topic:using a hashmap in Acceleo
Next Topic:[Acceleo] Where to get it from?
Goto Forum:
  


Current Time: Sun Apr 22 10:41:25 GMT 2018

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

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