Sequence manipulation [message #50676] |
Mon, 18 February 2008 00:28 |
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 12:41 |
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 14:27 |
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.
|
|
|
Powered by
FUDForum. Page generated in 0.05361 seconds