Coerce objects to a virtual function. Numeric or complex arguments are coerced to a constant function.

as.vf(x)

Arguments

x

Generally, a function or numeric

Value

Returns an object of class vf.

Author

Robin K. S. Hankin

Note

It is rarely necessary to coerce objects such as vectors or matrices to class vf because the Arith methods operate on objects of class ANY directly.

Examples

as.vf(\(x)x^2)
#> An object of class "vf"
#> function (x) 
#> x^2
#> <environment: 0x55a969a734e0>
Sin + as.vf(\(p){p^3})
#> An object of class "vf"
#> function (...) 
#> {
#>     e1(...) + e2(...)
#> }
#> <bytecode: 0x55a96b72d848>
#> <environment: 0x55a969946830>

as.vf(1:10)(1e99)
#>  [1]  1  2  3  4  5  6  7  8  9 10