From a512940daa046cc529c679942431435175cd6903 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Tue, 8 Feb 2022 08:51:30 +0100 Subject: [PATCH] Document pcase-lambda * doc/lispref/control.texi (Destructuring with pcase Patterns): Document pcase-lambda (bug#20268). --- doc/lispref/control.texi | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 -- 2.39.5