From: Blake Shaw <blake@reproduciblemedia.com>
To: guile-devel@gnu.org
Cc: Blake Shaw <blake@reproduciblemedia.com>
Subject: [PATCH v1 4/6] docs/match: match-let* unwrap example
Date: Fri, 27 Jan 2023 01:57:59 +0700 [thread overview]
Message-ID: <20230126185801.19064-4-blake@reproduciblemedia.com> (raw)
In-Reply-To: <20230126185801.19064-1-blake@reproduciblemedia.com>
[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
next prev parent reply other threads:[~2023-01-26 18:57 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-26 18:57 [PATCH v1 1/6] docs/match: add pattern matching examples Blake Shaw
2023-01-26 18:57 ` [PATCH v1 2/6] docs/match: rm unquote-splicing as it interferes with textinfo Blake Shaw
2023-01-27 16:27 ` Maxime Devos
2023-01-28 9:14 ` Blake Shaw
2023-01-28 13:08 ` Maxime Devos
2023-01-29 3:09 ` Blake Shaw
2023-01-26 18:57 ` [PATCH v1 3/6] docs/match: add reverse nested list example Blake Shaw
2023-01-26 18:57 ` Blake Shaw [this message]
2023-01-26 18:58 ` [PATCH v1 5/6] docs/fixup: @cindex was in the wrong place Blake Shaw
2023-01-26 18:58 ` [PATCH v1 6/6] docs/match:style reviewing with pdf, adding newlines Blake Shaw
2023-01-28 13:18 ` [PATCH v1 1/6] docs/match: add pattern matching examples Maxime Devos
2023-01-28 19:10 ` randomlooser
2023-01-28 19:23 ` randomlooser
[not found] ` <CAKjmbcA9TeuC0HWE53cG4EfautTcW5s9tyh0tCXUvicAQiBFKQ@mail.gmail.com>
2023-01-29 14:23 ` Maxime Devos
2023-01-28 13:48 ` Maxime Devos
[not found] ` <CAKjmbcAucYA9j7suY1gEAO512pn+90ED33Wq5Z7CjrBsqxgrbw@mail.gmail.com>
2023-01-29 15:30 ` Maxime Devos
2023-01-30 0:49 ` Blake Shaw
2023-01-30 19:56 ` Aleix Conchillo Flaqué
2023-01-30 19:57 ` Aleix Conchillo Flaqué
2023-01-31 2:53 ` Maxime Devos
2023-01-31 3:59 ` Aleix Conchillo Flaqué
2023-01-31 2:28 ` [PATCH v1 1/6] docs/match: add pattern matching examples + CoC Maxime Devos
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230126185801.19064-4-blake@reproduciblemedia.com \
--to=blake@reproduciblemedia.com \
--cc=guile-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).