# [R] Is k equivalent to k:k ?

Martin Maechler maechler at stat.math.ethz.ch
Fri Dec 10 09:34:11 CET 2004

```I'm diverting to R-devel, where this is really more
appropriate.  Here (R-help) only a shorter version:

>>>>> "RichOK" == Richard A O'Keefe <ok at cs.otago.ac.nz>
>>>>>     on Fri, 10 Dec 2004 14:37:16 +1300 (NZDT) writes:

RichOK> In this discussion of seq(), can anyone explain to
RichOK> me _why_ seq(to=n) and seq(length=3) have different
RichOK> types?

well, the explantion isn't hard:  look at  seq.default  :-)

RichOK> In fact, it's worse than that (R2.0.1):

>> storage.mode(seq(length=0))
RichOK>     [1] "integer"
>> storage.mode(seq(length=1))
RichOK>     [1] "double"

{ str(.) is shorter than  storage.mode(.) }

RichOK> If you want to pass seq(length=n) to a .C or
RichOK> .Fortran call, it's not helpful that you can't tell
RichOK> what the type is until you know n!  It would be nice
RichOK> if seq(length=n) always returned the same type.  I
RichOK> use seq(length=n) often instead of 1:n because I'd
RichOK> like my code to work when n == 0; it would make life
RichOK> simpler if seq(length=n) and 1:n were the same type.

now if that really makes your *life* simpler, what does that