Skip to main content



      Home
Home » Modeling » OCL » extract elements from a collection
extract elements from a collection [message #715339] Sat, 13 August 2011 08:57 Go to next message
Eclipse UserFriend
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 12:41 Go to previous messageGo to next message
Eclipse UserFriend
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 05:38 Go to previous messageGo to next message
Eclipse UserFriend
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 06:03] by Moderator

Re: extract elements from a collection [message #716201 is a reply to message #716044] Tue, 16 August 2011 12:25 Go to previous message
Eclipse UserFriend
> 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: Wed Jul 23 17:50:30 EDT 2025

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

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

Back to the top