[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.m2t] Re: [MTL] How to reverse lists ?

Hi,

Thanks a lot for using Acceleo
You have to put the tag [Acceleo] at the beginning of the subject (and not MTL)
MTL is the name of the OMG standard, so we can understand ;-)
but the name of the eclipse implementation is Acceleo


Cheers,

Jonathan




Guillaume Bourel a écrit :
Max Bureck a écrit :
I don't know about hidden features of Acceleo, but it seems that OCL does not provide such a method on Collections and the MOF Model To Text standard does not include such a method in it's library. Here is a query I used for creating a new sequence that contains the elements in reverse order:

[query reverse(s : Collection(T)) : Sequence(T) =
s->iterate(x; acc : Sequence(T) = Sequence{} | acc->prepend(x) )/]


You will have troubles with the returned collection, due to the inferred type of the sequence. Here is an example how to use it:

[template operationInfo(o : Operation)]
Operation name: [o.name/]
Parameters (reverse): [o.ownedParameter->reverse()->collect(oclAsType(uml::Parameter)).name/] [/template]


I hope this helps.

It works well :)

Thanks a lot Mr.Bureck !