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 3/6] docs/match: add reverse nested list example Date: Fri, 27 Jan 2023 01:57:58 +0700 Message-ID: <20230126185801.19064-3-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="24275"; 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:44:30 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 1pLDn3-0006A6-G4 for guile-devel@m.gmane-mx.org; Fri, 27 Jan 2023 02:44:29 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pLDmM-0004WO-HZ; Thu, 26 Jan 2023 20:43:46 -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-0008Rl-0T for guile-devel@gnu.org; Thu, 26 Jan 2023 13:58:32 -0500 Original-Received: from out2.migadu.com ([2001:41d0:2:aacc::]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pL7S9-0007UQ-Vt for guile-devel@gnu.org; Thu, 26 Jan 2023 13:58:31 -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=1674759507; 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=JjGBkqaFkPEE1WCkUlNKnOdyZDECCctedx67Pc4O2Bs=; b=W500QezoIDOiEhl+WUQnPBXcahLuL/xx68xWqyVBt5wtgNKh03TCLsm0CFqby+P0/WYdm9 G4d98l2/z3LcShY10qQhc8WyHMmnunW8jRW75FdVChzUAz6CuU9pGFxtRCVD4w1gRGAj88 MNQvIVa7i3AJ/5i1TiT4YVgt68HpC1E= In-Reply-To: <20230126185801.19064-1-blake@reproduciblemedia.com> X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:2:aacc::; envelope-from=blake@reproduciblemedia.com; helo=out2.migadu.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, 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:21643 Archived-At: --- doc/ref/match.texi | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/ref/match.texi b/doc/ref/match.texi index c5017e1a5..567146a35 100644 --- a/doc/ref/match.texi +++ b/doc/ref/match.texi @@ -112,6 +112,13 @@ extract the elements that make it up. @result{} ((1 . b) (2 . d) (3 . f)) @end example +@example +(match '(((a b c) e f g) 1 2 3) + ((((head ...) . rest) tails ...) + (acons tails head rest ))) +@result {} (((1 2 3) a b c) e f g) +@end example + Patterns can represent any Scheme object: lists, strings, symbols, records, etc. @@ -135,8 +142,7 @@ the corresponding elements of the object. (match m ((e) e) ((e1 e2 es ...) - (acons e1 e2 - (re es))))) + (acons e1 e2 (re es))))) @result{} ((a . b) (c . d) (e . f) (g . h) . i) @end example -- 2.39.1