[Rd] ranges and contiguity checking

James Bullard bullard at stat.Berkeley.EDU
Wed May 12 20:18:16 CEST 2010


Hi All,

I am interfacing to some C libraries (hdf5) and I have methods defined for
'[', these methods do hyperslab selection, however, currently I am
limiting slab selection to contiguous blocks, i.e., things defined like:
i:(i+k). I don't do any contiguity checking at this point, I just grab the
max and min of the range and them potentially do an in-memory subselection
which is what I am definitely trying to avoid. Besides using deparse, I
can't see anyway to figure out that these things (i:(i+k) and c(i, i+1,
..., i+k)) are different.

I have always liked how 1:10 was a valid expression in R (as opposed to
python where it is not by itself.), however I'd somehow like to know that
the thing was contiguous range without examining the un-evaluated
expression or worse, all(diff(i:(i+k)) == 1)

thanks, jim



More information about the R-devel mailing list