Open MarcusKlik opened 6 years ago
Such a method could also serve as a general range detector:
# another range
is_range(10:100)
#> [1] TRUE
If we can store ranges alongside random row selections (see also #29), that might be useful as well.
With R 3.5.0
and further, ranges can be detected much more easily because they are implemented with the ALTREP framework (so no custom range detection is needed anymore).
By providing a helper
C
method, we can test for a range without creating intermediate vectors.A first (non-optimized) try:
That's fast enough for practical purposes I think. Perhaps the method above can be improved by chunking the vector and determining the sum of squares of the vector minus the expected vector.
(that would minimize the number of
if
statements and may improve CPU throughput)