The Wayback Machine - https://web.archive.org/web/20220901002211/https://www.geeksforgeeks.org/check-if-a-function-is-a-primitive-function-in-r-programming-is-primitive-function/
Skip to content
Related Articles

Related Articles

Check if a Function is a Primitive Function in R Programming – is.primitive() Function

View Discussion
Improve Article
Save Article
  • Last Updated : 05 Jun, 2020
View Discussion
Improve Article
Save Article

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:




# R program to illustrate 
# the use of is.primitive function
  
# Calling is.primitive() function
is.primitive(1)
is.primitive(is.primitive)
is.primitive(sum)
is.primitive(prod)

Output:

[1] FALSE
[1] FALSE
[1] TRUE
[1] TRUE

Example 2:




# R program to illustrate 
# the use of is.primitive function
  
# Sample user-defined Function
evenOdd = function(x){ 
  if(x %% 2 == 0) 
    return("even") 
  else
    return("odd") 
}  
  
# Calling is.primitive() function
is.primitive(evenOdd)

Output:

[1] FALSE
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!