Archive for the ‘Lisp’ Category

Articles

Lisp, how to test if a symbol is a function

In Lisp on 18/03/2010 by pier0w Tagged: , , ,

If for some reason when on your Lisp journey you come across an errant symbol and wish to check whether it is a function or not, it can be done with fboundp. This function will return T if the symbol is a function or NIL if it is not.

For an example run the following code within your favourite Lisp environment:

(defun test () "I AM A TEST!")
(fboundp 'test)
(fboundp 'this-symbol-should-hopefully-not-be-a-function)

You should get the following output.

T
NIL

Advertisements

Comments Off on Lisp, how to test if a symbol is a function