This is how you check if an object is a built-in function:
(subrp (symbol-function 'assoc))
=> t
Is there an equivalent way to do this for variables as well?
This is how you check if an object is a built-in function:
(subrp (symbol-function 'assoc))
=> t
Is there an equivalent way to do this for variables as well?
I assume that by "built-in" you mean a variable defined in C. This should do it:
(defun built-in-var-p (variable)
"Return non-nil if VARIABLE is defined in C source code."
(let ((file-name (find-lisp-object-file-name variable 'defvar)))
(and file-name (eq file-name 'C-source))))