Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » How to get a descreasing ordered sequence?
How to get a descreasing ordered sequence? [message #34661] Sun, 29 July 2007 10:37 Go to next message
Eclipse User
Originally posted by: zzhangh.cn.ibm.com

Hi,
sortedBy() can return a increasing sequence, I'd like to know how to get a
descreasing sequence in OCL, thanks!

Hao
Re: How to get a descreasing ordered sequence? [message #34695 is a reply to message #34661] Mon, 30 July 2007 02:44 Go to previous messageGo to next message
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 02:45 Go to previous message
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
Previous Topic:how to call a user defined operation.
Next Topic:[Announce] OCL Tools component proposal
Goto Forum:
  


Current Time: Fri Aug 01 08:08:59 EDT 2014

Powered by FUDForum. Page generated in 0.02236 seconds