Closed RobinHankin closed 1 year ago
There is a more general bug. Look:
> as.function(as.cycle(1:6))(9)
Error in x[, a] : subscript out of bounds
>
Above, I would expect the call to return 9
on the reasonable grounds that the cycle (123456)
leaves numbers >=7
unchanged.
There is a sort of fix:
o <- as.word(as.cycle(1:2))
> as.function(o)(4)
Error in x[, a] : subscript out of bounds
> size(o) <- 6
> as.function(o)(4)
[1] 4
>
The first call returns an error, but not the second. This should be documented.
This works:
But this doesn't:
I wonder whether it would be a good idea to include special dispensation in
as.function.permutation()
to check for its argument being the identity and, if so, returnfunction(x){x}
. Not sure whether this would break something.