How to call lambda passed a parameter in LISP
elisp, lisp
Solution
You want to use `funcall`.
funcall is a built-in function in `C source code'.
(funcall FUNCTION &rest ARGUMENTS)
Call first argument as a function, passing remaining arguments to it. Return the value that function returns. Thus, (funcall 'cons 'x 'y) returns (x . y).
Problem
Possible Duplicate: How to pass a lambda expression in Elisp I have following code: ``` (defun my-map (p l) (mapcar (lambda (el) (p el)) l)) (defun test () (my-map (lambda (x) (+ x 1)) (list 1 2 3))) ``` (It's example - not actual code I tried to write). It complains that it cannot find function p: ``` Debugger entered--Lisp error: (void-function p) (p el) (lambda (el) (p el))(1) mapcar((lambda (el) (p el)) (1 2 3)) my-map((lambda (x) (x + 1)) (1 2 3)) test() eval((test) nil) eval-expression((test) nil) call-interactively(eval-expression nil nil) recursive-edit() debug(error (void-variable test)) eval(test nil) eval-expression(test nil) call-interactively(eval-expression nil nil ``` I guess that it treats a `p` as symbol and not variable bounded in outer scope. How to make it work?