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

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)

chevron_right


Output:

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

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)

chevron_right


Output:

[1] FALSE
My Personal Notes arrow_drop_up

Recommended Posts:


Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.