Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Sequence manipulation
Sequence manipulation [message #50676] Sun, 17 February 2008 19:28 Go to next message
Eclipse User
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 07:41 Go to previous messageGo to next message
Eclipse User
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 09:27 Go to previous message
Eclipse User
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: Tue Sep 02 08:02:05 EDT 2014

Powered by FUDForum. Page generated in 0.01886 seconds