Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » extract elements from a collection
extract elements from a collection [message #715339] Sat, 13 August 2011 12:57 Go to next message
AmenieV  is currently offline AmenieV
Messages: 13
Registered: June 2011
Junior Member
Hi,

How can I extract such elements from a collection T,
for example,for recovering the second element we do collection -> at (2)
but I want to recover the second,third and sixth element for example, what should I do?

Thankx,
Regards
AmenieVal
Re: extract elements from a collection [message #715381 is a reply to message #715339] Sat, 13 August 2011 16:41 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4116
Registered: July 2009
Senior Member
Hi

Sequence{2,3,6}->collect(i | aCollection->at(i))

Regards

Ed Willink

On 13/08/2011 13:57, AmenieV wrote:
> Hi,
>
> How can I extract such elements from a collection T,
> for example,for recovering the second element we do collection -> at (2)
> but I want to recover the second,third and sixth element for example,
> what should I do?
>
> Thankx,
> Regards
> AmenieVal
Re: extract elements from a collection [message #716044 is a reply to message #715381] Tue, 16 August 2011 09:38 Go to previous messageGo to next message
AmenieV  is currently offline AmenieV
Messages: 13
Registered: June 2011
Junior Member
Thankx for your reply Ed !

but I want to do loop on elements of the sequence,, such as I want to recover elem whis index=i and i = i +4
Do you understand me?

and how can I compare elements of two sequences?
for instance, sequence{1,3,4} must be > sequence{4,0,1}

Thanks a lot Ed,

Regards,
AmenieVal

[Updated on: Tue, 16 August 2011 10:03]

Report message to a moderator

Re: extract elements from a collection [message #716201 is a reply to message #716044] Tue, 16 August 2011 16:25 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4116
Registered: July 2009
Senior Member
> but I want to do loop on elements of the sequence,, such as I want to
> recover elem whis index=i and i = i +4 Do you understand me?
No.

In

> Sequence{2,3,6}->collect(i | aCollection->at(i))

2,3,6 can be arbitrary expressions and at(i) can be an exprression.

The secret of writing OCL is to write what you want in 'English' and
gradually formalize it and then suddenly the OCL is obvious.

Until you can express what you want to do clearly, you are unlikely to
be able to program it in any language.

Regards

Ed Willink
Previous Topic:at() in OCLinEcore
Next Topic:OCLSettingDelegate extension
Goto Forum:
  


Current Time: Sat Nov 01 11:19:38 GMT 2014

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

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