|
Re: How to get a descreasing ordered sequence? [message #34695 is a reply to message #34661] |
Mon, 30 July 2007 06:44 |
Eclipse User |
|
|
|
Originally posted by: firstname.name.gmail.com
In the last post, on 07/29 about 04h, "Hao" (Hao Zhang) wrote:
Hao> Hi, sortedBy() can return a increasing sequence, I'd like to know
Hao> how to get a descreasing sequence in OCL, thanks!
sortedBy computes a order given a expression that you have to provide. Hence, for
example if you want to build a set of members of package, ordered by the length of
their names you can use something:
context is a package:
self.ownedMember->sortedBy(name.size())
to change the order
self.ownedMember->sortedBy(-name.size())
--
F. Lagarde
|
|
|
Re: How to get a descreasing ordered sequence? [message #34728 is a reply to message #34695] |
Tue, 31 July 2007 06:45 |
Eclipse User |
|
|
|
Originally posted by: firstname.name.gmail.com
In the last post, on 07/30 about 08h, "François" (François Lagarde) wrote:
François> Hence, for example if you want to build a set of members of
François> package, ordered by the length of their names you can use
François> something
I reply to myself. I read what was your question. My answer is not really clear
or/and unproper. You can maybe use a more generic way to inverting a
OrderedSet. Something like, (context is still a package):
let t: OrderedSet(uml::NamedElement) =
self.ownedMember->sortedBy(name) in
Sequence{1..t->size()}->iterate(i; e:OrderedSet(uml::NamedElement)=OrderedSet{} |
e->append(t->at(1+(t->size())-i)))
--
F. Lagarde
|
|
|
Powered by
FUDForum. Page generated in 0.03302 seconds