Higher-order functions in Elisp
I created a function that returns a function in Elisp: (defun singleton-set (elem) (defun f (n) (= n elem)) f) I try to run this in IELM, and it fails: ELISP> (singleton-set 5) *** Eval error *** Symbol's value as variable is void: f ELISP> ((singleton-set 5) 5) *** Eval error *** Invalid function: (singleton-set 5) Due to What is the difference between Lisp-1 and Lisp-2? i changed the code to (defun singleton-set (elem) (defun f (n) (= n elem)) #'f) And invocation to (funcall (singleton-set 5) 5) , but now the error is *** Eval error *** Symbol's value as variable is void: elem I understand