Demonstrate usage of a lambda function in a let expression

This commit is contained in:
Bram Schoenmakers 2022-12-13 18:05:06 +01:00
parent 3556a128ec
commit 7335c0fc95
2 changed files with 15 additions and 0 deletions

View file

@ -300,6 +300,15 @@ My vertico-repeat setup.
")")))
")")))))
,#+end_example
* Define a lambda in a let expression
#+begin_src elisp :tangle gists/let-lambda.el
(let ((f (lambda (s) (message s))))
;; f is a variable so should be treated as such.
(funcall f "This works.")
;; f is not a function so cannot be found if called like this.
(f "This does not work."))
#+end_src
* Meta

6
gists/let-lambda.el Normal file
View file

@ -0,0 +1,6 @@
(let ((f (lambda (s) (message s))))
;; f is a variable so should be treated as such.
(funcall f "This works.")
;; f is not a function so cannot be found if called like this.
(f "This does not work."))