One very common bug in R is that people call 1:n in situations where n can be 0.
Calling 1:0 leads to the sequence [1, 0], whereas the intended behavior was often to get an empty vector, i.e. integer(0).
While there is seq_len in R, it is still something that beginners first have to (un)learn, as calling 1:n seems to be the natural thing to do. Some time ago, I also read an article that this is also a problem in Julia.
I think, we should just make the : operator require lhs <= rhs.
For decreasing sequences, we could either refer to a seq() function or implement rev() for reversing a vector (ideally using the future RepType::Iterator.
One very common bug in R is that people call
1:n
in situations wheren
can be0
. Calling1:0
leads to the sequence[1, 0]
, whereas the intended behavior was often to get an empty vector, i.e.integer(0)
. While there isseq_len
in R, it is still something that beginners first have to (un)learn, as calling1:n
seems to be the natural thing to do. Some time ago, I also read an article that this is also a problem in Julia.I think, we should just make the
:
operator requirelhs <= rhs
. For decreasing sequences, we could either refer to aseq()
function or implementrev()
for reversing a vector (ideally using the futureRepType::Iterator
.