Passing Functions as Arguments
Posted: Tue Jun 14, 2011 9:28 am
How does one go about doing functional programming in Emacs Lisp?
They say that Lisp is a "functional" language, so you'd think it should be straightforward, but after googling around I've found comments from people to the effect that "functional programming in elisp is difficult to impossible"..
For instance, what I'm trying to do is something akin to:
The above idiom will work in Scheme or Python, but Emacs Lisp doesn't seem to like it.
Is there a way to pass functions as arguments in Emacs Lisp?
They say that Lisp is a "functional" language, so you'd think it should be straightforward, but after googling around I've found comments from people to the effect that "functional programming in elisp is difficult to impossible"..
For instance, what I'm trying to do is something akin to:
Code: Select all
(defun f (x) (+ x 1))
(f 1)
;; 2
(defun x (y) (y 1))
(x f)
;; you could expect "2", but instead get a "void variable" error
Is there a way to pass functions as arguments in Emacs Lisp?