anta40 wrote:Here's a function that takes a number N, and returns a function that adds N to its argument (taken from Practical Common Lisp):

- Code: Select all
`(defun add-n (n)`

#'(lambda (x)

(+ x n)))

My guess was something like this should work:

- Code: Select all
`((add-n 1) 2)`

Unfortunately, it doesn't work. Further investigation:

- Code: Select all
`? (functionp 'add-n)`

NIL

Now I'm confused. How can I use this add-n properly?

(first, it's not a lambda function. It is either anonymous function or a lambda expression)

'add-n is a symbol. But #'add-n is a function. (add-n 10) is also a function.

The expression ((add-n 1) 2) works in scheme, in common lisp you should use funcall:

- Code: Select all
`(funcall (add-n 1) 2)`

(For details, see information about Lisp-1 vs Lisp-2)