Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Sequence manipulation
Sequence manipulation [message #50676] Mon, 18 February 2008 00:28 Go to next message
Eclipse UserFriend
Originally posted by: no.email.com

Hi all,

I was wondering why the following expression :

let seq : Sequence(Sequence(String)) =
Sequence{Sequence{'a'}, Sequence{'b'}, Sequence{}, Sequence{}} in (
seq -> excluding( seq->last() )
)

evaluates to Sequence{Sequence{'a'}, Sequence{'b'}}
and not Sequence{Sequence{'a'}, Sequence{'b'}, Sequence{}} ?

I know I can get what I want by using a subSequence(1,seq->size()-1) but
I find the way the excluding works here strange.
Re: Sequence manipulation [message #50704 is a reply to message #50676] Mon, 18 February 2008 12:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: no.email.com

Hmm,
In fact my question was dumb. seq->last() evaluates to Sequence{}. And
as excluding removes all the elements in the sequence that match the one
in parameter, it's quite natural that the 2 sequence{} elements are removed.

Alain MICHEL a écrit :
> Hi all,
>
> I was wondering why the following expression :
>
> let seq : Sequence(Sequence(String)) =
> Sequence{Sequence{'a'}, Sequence{'b'}, Sequence{}, Sequence{}} in (
> seq -> excluding( seq->last() )
> )
>
> evaluates to Sequence{Sequence{'a'}, Sequence{'b'}}
> and not Sequence{Sequence{'a'}, Sequence{'b'}, Sequence{}} ?
>
> I know I can get what I want by using a subSequence(1,seq->size()-1) but
> I find the way the excluding works here strange.
Re: Sequence manipulation [message #50732 is a reply to message #50704] Tue, 19 February 2008 14:27 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Alain,

Right, the "excluding" operation ensures that the supplied object does not
exist in the collection, and Collections (being data types) are
value-based, not identity-based, so all equal occurrences are removed.

Cheers,

Christian

Alain MICHEL wrote:

> Hmm,
> In fact my question was dumb. seq->last() evaluates to Sequence{}. And
> as excluding removes all the elements in the sequence that match the one
> in parameter, it's quite natural that the 2 sequence{} elements are
> removed.
>
> Alain MICHEL a écrit :
>> Hi all,
>>
>> I was wondering why the following expression :
>>
>> let seq : Sequence(Sequence(String)) =
>> Sequence{Sequence{'a'}, Sequence{'b'}, Sequence{}, Sequence{}} in (
>> seq -> excluding( seq->last() )
>> )
>>
>> evaluates to Sequence{Sequence{'a'}, Sequence{'b'}}
>> and not Sequence{Sequence{'a'}, Sequence{'b'}, Sequence{}} ?
>>
>> I know I can get what I want by using a subSequence(1,seq->size()-1) but
>> I find the way the excluding works here strange.
Previous Topic:[Announce] MDT OCL 1.2.0M5 is available
Next Topic:Backslashes in string literals for version 1.0.1
Goto Forum:
  


Current Time: Thu Apr 18 23:01:10 GMT 2024

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

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

Back to the top