What you are missing here is how the Common Lisp reading and evaluation works.
When you give CL text, e.g.,
(apply (first '(numberp)) '(17))
the reader (you can invoke it yourself!) parses it into the following list:
(apply (first (quote (numberp))) (quote (17)))
(note that '
is just syntactic sugar for quote
) which is then evaluated like this:
- take the function binding of the first element of the list,
apply
- evaluate the second list element:
- take the function binding of
first
- evaluate the second list element:
- since it is quoted, take it as is, get list of length 1 with element
numberp
- apply
first
to that list, get numberp
- evaluate the 3rd list element:
- since it is quoted, it is just the thing under
quote
, i.e., list of length 1 with element 17
- apply the first function (
apply
) to the arguments, i.e., apply the (function binding of) numberp
to the list of one element - 17.
Your 2nd form differs from the 1st in that you have symbol numberp
which is evaluated as a variable and thus you get your error.
In your 3rd form you use #'numberp
which the reader transforms to (function numberp)
which returns a function value which can be applied to the list.
In short, this is the result of Common Lisp being Lisp-2.
You might also find When to use 'quote in Lisp instructive.