[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 4/6] docs/match: match-let* unwrap example
From: |
Blake Shaw |
Subject: |
[PATCH v1 4/6] docs/match: match-let* unwrap example |
Date: |
Fri, 27 Jan 2023 01:57:59 +0700 |
[pdf] now builds, but there are some spacing issues I want to correct
in the PDF, that will be introduced next.
---
doc/ref/match.texi | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/doc/ref/match.texi b/doc/ref/match.texi
index 567146a35..4f3dc86fc 100644
--- a/doc/ref/match.texi
+++ b/doc/ref/match.texi
@@ -248,7 +248,7 @@ The names @code{quote}, @code{quasiquote}, @code{unquote},
@code{or}, @code{not}, @code{set!}, @code{get!}, @code{...}, and
@code{___} cannot be used as pattern variables.
-Here is a more complex example:
+Here is a more complex example using records and promises:
@example
(use-modules (srfi srfi-9))
@@ -361,11 +361,22 @@ bind the variables in sequence, with preceding match
variables in scope.
(match-let (((x y) (list 1 2)))
(match-let (((a b) (list x 4)))
(list a b x y)))
-@result{}
-(1 4 1 2)
+@result{} (1 4 1 2)
@end example
@end deffn
+@example
+(define wrap '(((((unnest arbitrary nestings))))))
+
+(let unwrap ((peel wrap))
+ (match-let* ([([core ...]) peel]
+ [(wrapper ...) core])
+ (if (> (length wrapper) 1)
+ wrapper
+ (unwrap wrapper))))
+@result{} (unnest arbitrary nestings)
+@end example
+
@deffn {Scheme Syntax} match-letrec ((variable expression) @dots{}) body
Similar to @code{match-let}, but analogously to @code{letrec}, match and
bind the variables with all match variables in scope.
--
2.39.1
[PATCH v1 3/6] docs/match: add reverse nested list example, Blake Shaw, 2023/01/26
[PATCH v1 6/6] docs/match:style reviewing with pdf, adding newlines, Blake Shaw, 2023/01/26
[PATCH v1 4/6] docs/match: match-let* unwrap example,
Blake Shaw <=
[PATCH v1 5/6] docs/fixup: @cindex was in the wrong place, Blake Shaw, 2023/01/26
Re: [PATCH v1 1/6] docs/match: add pattern matching examples, Maxime Devos, 2023/01/28
Re: [PATCH v1 1/6] docs/match: add pattern matching examples, Maxime Devos, 2023/01/28