Consider the following:
>> library(Rmpfr)
>> seq(mpfr(1,10),mpfr(5,10),by=1)
5 'mpfr' numbers of precision 10 bits
[1] 1 2 3 4 5
>> seq(1,mpfr(5,10),by=1)
[[1]]
[1] 1
[[2]]
[1] 2
[[3]]
[1] 3
[[4]]
[1] 4
[[5]]
[1] 5
>> seq(mpfr(1,10),5,by=1)
Error in max(abs(to), abs(from)) : invalid 'type' (list) of argument
>> methods(seq)
[1] seq.Date seq.default seq.POSIXt seq.units*
see '?methods' for accessing help and source code
We see there is no method for mpfr
objects, yet with a little coaxing, seq()
will provide the correct result. But the class of the result depends on just what gets coerced when.
Anyone know what’s going on inside seq
? Am I just getting “lucky” that this works at all