From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Blake Shaw Newsgroups: gmane.lisp.guile.devel Subject: [PATCH v1 4/6] docs/match: match-let* unwrap example Date: Fri, 27 Jan 2023 01:57:59 +0700 Message-ID: <20230126185801.19064-4-blake@reproduciblemedia.com> References: <20230126185801.19064-1-blake@reproduciblemedia.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27303"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Blake Shaw To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Fri Jan 27 02:45:08 2023 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pLDnf-0006qx-C0 for guile-devel@m.gmane-mx.org; Fri, 27 Jan 2023 02:45:07 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pLDmQ-0004Xx-UK; Thu, 26 Jan 2023 20:43:51 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pL7SC-0008SD-Uk for guile-devel@gnu.org; Thu, 26 Jan 2023 13:58:32 -0500 Original-Received: from out2.migadu.com ([188.165.223.204]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pL7SA-0007bO-Uy for guile-devel@gnu.org; Thu, 26 Jan 2023 13:58:32 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=reproduciblemedia.com; s=key1; t=1674759509; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hMGgE6BmIisjmwFlP2iQdHG8R2a42WxcuD1+tLCdqOo=; b=UIXkTeA9VDA3DDTxQ38aRVe3EyWd+4gnNA8uJTeZtRjM9TUl9RkPtzSzq2aMiTgQ7tfnpD FG7PVhQpHhRGbYEgA6y38F7UHnCZbmnnNQMZ76pDK5NFYKWCnVc13Ik7dz1Koms6bqF5qD anSft9ipXw/fbcF6Cw9grhySNv/5f7o= In-Reply-To: <20230126185801.19064-1-blake@reproduciblemedia.com> X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=188.165.223.204; envelope-from=blake@reproduciblemedia.com; helo=out2.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 26 Jan 2023 20:43:44 -0500 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.devel:21644 Archived-At: [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