docs(emacs-lisp): add fn! & lambda! demos
This commit is contained in:
parent
23feb482e9
commit
00c75eddf8
1 changed files with 37 additions and 0 deletions
|
@ -327,6 +327,43 @@ Or to create aliases for functions that behave differently:
|
||||||
";" (kbd! ":"))
|
";" (kbd! ":"))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
** lambda!
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(mapcar (lambda! ((&key foo bar baz))
|
||||||
|
(list foo bar baz))
|
||||||
|
'((:foo 10 :bar 25)
|
||||||
|
(:baz hello :boop nil)
|
||||||
|
(:bar 42)))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+RESULTS:
|
||||||
|
: ((10 25 nil) (nil nil hello) (nil 42 nil))
|
||||||
|
|
||||||
|
** fn!
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(mapcar (fn! (symbol-name %)) '(hello world))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+RESULTS:
|
||||||
|
: ("hello" "world")
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(seq-sort (fn! (string-lessp (symbol-name %1)
|
||||||
|
(symbol-name %2)))
|
||||||
|
'(bonzo foo bar buddy doomguy baz zombies))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+RESULTS:
|
||||||
|
: (bar baz bonzo buddy doomguy foo zombies)
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(format "You passed %d arguments to this function"
|
||||||
|
(funcall (fn! (length %*)) :foo :bar :baz "hello" 123 t))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+RESULTS:
|
||||||
|
: "You passed 6 arguments to this function"
|
||||||
|
|
||||||
** letenv!
|
** letenv!
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:added: pre-3.0.0
|
:added: pre-3.0.0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue