2

my elisp program is:

(defun test (f x) (f x))
(test (lambda (x) (* x x)) 10)

run it, an error happened:

* Eval error * Symbol's function definition is void: f

2 Answers 2

9

Emacs is a lisp-2, so has a different namespace for functions and variables. So, in test, the f in the second (f x) is not the same as the (f) in the parameter list.

Try

(defun test (f x) (funcall f x))

All is good.

1

Here's the correction:

(defun test (f x)
  (funcall f x))

(test (lambda (x) (* x x)) 10)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.