From: Lars Ingebrigtsen Date: Tue, 8 Feb 2022 07:51:30 +0000 (+0100) Subject: Document pcase-lambda X-Git-Tag: emacs-29.0.90~2433 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a512940daa046cc529c679942431435175cd6903;p=emacs.git Document pcase-lambda * doc/lispref/control.texi (Destructuring with pcase Patterns): Document pcase-lambda (bug#20268). --- diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi index 634d46a7854..2f1666ba771 100644 --- a/doc/lispref/control.texi +++ b/doc/lispref/control.texi @@ -1326,6 +1326,20 @@ Assign values to variables in a @code{setq} form, destructuring each @var{value} according to its respective @var{pattern}. @end defmac +@defmac pcase-lambda lambda-list &rest body +This is like @code{lambda}, but allows each argument to be a pattern. +For instance, here's a simple function that takes a cons cell as the +argument: + +@example +(setq fun + (pcase-lambda (`(,key . ,val)) + (vector key (* val 10)))) +(funcall fun '(foo . 2)) + @result{} [foo 20] +@end example +@end defmac + @node Iteration @section Iteration @cindex iteration