in R
pretty much everything that is not a variable of another type is a function.
It seems that function
itself is one :
`function`
# .Primitive("function")
Though I'm not sure, it doesn't return the same thing as say +
:
`+`
# function (e1, e2) .Primitive("+")
It seems it's possible to call it though :
formals(`function`)
# NULL
`function`(x)
# Error: incorrect number of arguments to "function"
`function`(x,y)
# Error: invalid formal argument list for "function"
`function`(x,y,3,4,5,6,7,8,9,10)
# Error: invalid formal argument list for "function"
How (if possible at all) could we define a simple function such as this one:
plus <- function(x,y) x+y
Here's what I tried:
plus <- `function`(x,y,expression(x+y))
# Error: invalid formal argument list for "function"
Before you ask, I'm just curious, I don't have any practical use case in mind.