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, a
(defun singleton-set (elem) `(lambda (n) (= n ,elem))
See: elisp functions as parameters and as return value