In chapter 3 of Practical Common Lisp book there's an example of a SQL-like select and where functions. Here's a simplified version of it:
(defun where (x)
#'(lambda (item)
(> item x)))
and it is used like this:
(remove-if-not (where 2) (list 1 2 3 4))
Earlier in the book it is explained that the #'
sequence is used to state that it is followed by a function name, rather than a variable that requires evaluation. I don't understand why it's needed here. I tried implementing the where
function without it and it worked as well:
(defun where (x)
(lambda (item)
(> item x)))
I tried googling for it, and, as you can imagine, with such a sequence of characters it wasn't a very fruitful search. And I don't know the name of this thing.
Is there any particular reason why it's needed in the above code?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…