functionp
functionp Function
Syntax:
functionp object → generalized-boolean
Arguments and Values:
object—an object.
generalized-boolean—a generalized boolean.
Description:
Returns true if object is of type function; otherwise, returns false.
Examples:
(functionp ’append) → false
(functionp #’append) → true
(functionp (symbol-function ’append)) → true
(flet ((f () 1)) (functionp #’f)) → true
(functionp (compile nil ’(lambda () 259))) → true
(functionp nil) → false
(functionp 12) → false
(functionp ’(lambda (x) (\* x x))) → false
(functionp #’(lambda (x) (\* x x))) → true
Notes:
(functionp object) ≡ (typep object ’function)
Expanded Reference: functionp
Testing Various Objects
functionp returns true if its argument is a function object. Symbols and lambda expressions are not functions -- you need #' or (function ...) to get the actual function object.
;; Function objects
(functionp #'car)
=> T
(functionp #'+)
=> T
(functionp (lambda (x) x))
=> T
;; Not function objects
(functionp 'car)
=> NIL
(functionp 42)
=> NIL
(functionp "hello")
=> NIL
(functionp '(lambda (x) x))
=> NIL
Compiled and Interpreted Functions
Both compiled and interpreted function objects satisfy functionp.
(functionp (compile nil (lambda (x) (1+ x))))
=> T
(functionp #'(lambda (x) (1+ x)))
=> T
Equivalence to typep
functionp is equivalent to (typep object 'function).
(let ((f #'list))
(values (functionp f)
(typep f 'function)))
=> T
=> T
(let ((s 'list))
(values (functionp s)
(typep s 'function)))
=> NIL
=> NIL