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
Emacs is a lisp-2, so has a different namespace for functions and variables. So, in test, the f in the second (fx) is not the same as the (f) in the parameter list.
Try
(defun test (f x) (funcall f x))
All is good.
Here's the correction:
(defun test (f x)
(funcall f x))
(test (lambda (x) (* x x)) 10)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.