Check if a Function is a Primitive Function in R Programming – is.primitive() Function
Last Updated :
05 Jun, 2020
is.primitive()
function in R Language is used to check if a function is a primitive function, i.e. its either a built-in function or a special function.
Syntax: is.primitive(func)
Parameters:
func: Function to be checked
Example 1:
is .primitive( 1 )
is .primitive( is .primitive)
is .primitive( sum )
is .primitive(prod)
|
Output:
[1] FALSE
[1] FALSE
[1] TRUE
[1] TRUE
Example 2:
evenOdd = function(x){
if (x % % 2 = = 0 )
return ( "even" )
else
return ( "odd" )
}
is .primitive(evenOdd)
|
Output:
[1] FALSE
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...