extract elements from a collection [message #715339] |
Sat, 13 August 2011 08:57  |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
> 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
|
|
|
Powered by
FUDForum. Page generated in 0.03419 seconds