checkedSqrt <- function(x) {
return(sqrt(x))
}
typeInfo(checkedSqrt) <-
SimultaneousTypeSpecification(
TypedSignature(x=quote(
is(x, "numeric") && all(x>=0))))
typeInfo(checkedSqrt)
checkedSqrt(2)
try(checkedSqrt(-2))
Run the code above in your browser using DataLab