From i@uc@r86 @ending from gm@il@com  Sat Aug  4 16:51:42 2018
From: i@uc@r86 @ending from gm@il@com (=?UTF-8?B?ScOxYWtpIMOaY2Fy?=)
Date: Sat, 4 Aug 2018 16:51:42 +0200
Subject: [Rd] Is this a bug in `[`?
In-Reply-To: <4cf085ac-8f7e-38b5-ea02-302df94ad7b5@sapo.pt>
References: <4cf085ac-8f7e-38b5-ea02-302df94ad7b5@sapo.pt>
Message-ID: <CALEXWq2LxX7TUS5ia2R3o6GwxdkDZe_PZ=UZ1zfFWLTY1OTS=g@mail.gmail.com>

El s?b., 4 ago. 2018 a las 15:32, Rui Barradas
(<ruipbarradas at sapo.pt>) escribi?:
>
> Hello,
>
> Maybe I am not understanding how negative indexing works but
>
> 1) This is right.
>
> (1:10)[-1]
> #[1]  2  3  4  5  6  7  8  9 10
>
> 2) Are these right? They are at least surprising to me.
>
> (1:10)[-0]
> #integer(0)
>
> (1:10)[-seq_len(0)]
> #integer(0)
>
>
> It was the last example that made me ask, seq_len(0) whould avoid an
> if/else or something similar.

I think it's ok, because there is no negative zero integer, so -0 is 0.

1.0/-0L # Inf
1.0/-0.0 # - Inf

And the same can be said for integer(0), which is the result of
seq_len(0): there is no negative empty integer.

I?aki

>
>
> Thanks in advance,
>
> Rui Barradas
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] Is this a bug in `[`?
=?UTF-8?B?ScOxYWtpIMOaY2Fy?=