From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Ludovic_Court=C3=A8s?= Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCHv2] Extensions for SRFI-171 (Transducers) Date: Sat, 14 Jan 2023 16:09:56 +0100 Message-ID: <877cxp9mpn.fsf@gnu.org> References: <1158f7bf-3093-8c3b-dd74-267f1fbb6f4c@fosskers.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11067"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Cc: guile-devel@gnu.org, Linus =?utf-8?Q?Bj=C3=B6rnstam?= To: Colin Woodbury Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Sat Jan 14 16:10:16 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 1pGiAh-0002iO-Ry for guile-devel@m.gmane-mx.org; Sat, 14 Jan 2023 16:10:15 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pGiAT-0004bG-1i; Sat, 14 Jan 2023 10:10:01 -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 1pGiAR-0004b7-TV for guile-devel@gnu.org; Sat, 14 Jan 2023 10:10:00 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pGiAR-0003Zi-FM; Sat, 14 Jan 2023 10:09:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=xC38gcHbvMGFN0qZUYFnWy72KzWt7fvQVeTecmVXZmE=; b=K1KsECE51TG+oJpHdEJt xWjKGkEMo8wXfnFQZN0jMiBdvImjq5311LfeapG8wxYBy/kHaPcPD243W5Z0ysoFjDViKoUcrQ+4p YuaQ1pPVdK+s0+CA5IHjuFNVfsdrQDqbTmYQMkmn+jXVVDDgkY2LyfdPeSSFHzLFZoIIFY+iOKdAt O3nZ7RqRlDQtHYT6tqZePBrv666MwymEttkENAT/vAt85ZQzRjUy1teChFrauZ0Vq2hrv1/rSmL+C cpBxxfoyH4BDEneyXZyDrNDFi2BkMVy1TYwV+ZFsTYPIRR7MqlO3GfNd/7/FJNp5BxURoUgFALwsz S4XphK5BmU+ygA==; Original-Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pGiAQ-0002Mr-LY; Sat, 14 Jan 2023 10:09:59 -0500 X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Quintidi 25 =?utf-8?Q?Niv=C3=B4se?= an 231 de la =?utf-8?Q?R=C3=A9volution=2C?= jour du Chat X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu In-Reply-To: <1158f7bf-3093-8c3b-dd74-267f1fbb6f4c@fosskers.ca> (Colin Woodbury's message of "Sun, 25 Dec 2022 00:28:13 +0900") 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:21582 Archived-At: Hi Colin and all! These patches look like a nice addition. First, you have the option of assigning your copyright for this contribution (and future Guile contributions if you wish) to the FSF, or you can choose not to: https://lists.gnu.org/archive/html/guile-devel/2022-10/msg00008.html Please take a look at the message above and let us know what you=E2=80=99d = like to do. If you choose not to assign copyright, you=E2=80=99ll have to add copyright lines for you (or whatever entity holds copyright on your work) in the modified files. Overall the changes LGTM; I have minor comments and suggestions: Colin Woodbury skribis: > From 96856b184a507886db2c5c20323983ae125a6bdb Mon Sep 17 00:00:00 2001 > From: Colin Woodbury > Date: Mon, 19 Dec 2022 09:39:37 +0900 > Subject: [PATCH 1/4] srfi-171: add twindow and various reducers > > This adds a number of reduction primitives often seen in other languages > to Guile's SRFI-171 extensions. > > Most critical may be `rfold`, which could be called the fundamental > reducer, as it's likely that all other reducers could be defined in > terms of it (though not all are). While `tfold` already exists in > Guile's SRFI-171 extension as a transducer, folding is in essence a > reduction. Also without a primative like `rlast` (also introduced here), > the results of `tfold` are difficult to consume. This is avoided by > providing `rfold` directly as a generalised means to collapse an entire > transduction down into a single value (i.e. the whole point of > reducers). `rfold` is also useful for the creation of ad-hoc reducers, > as any 2-arg function can be passed to it to fold the stream of values. > > `rfirst`, `rlast`, and `rfind` are common idioms and so have been added. > > The equivalent of `rmax` and `rmin` are easy to write manually via > `rfold`, but they have been provided here as a convenience in the same > spirit as `rcons`. > > `rfor-each` also cannot be forgotten as a classic adaptation of its > SRFI-1 cousin. > > Also added is `twindow`, handy for analysing groups of adjacent items. [...] > From 58e7ca2718a860ca2fb5692684d6d128a7c1ae75 Mon Sep 17 00:00:00 2001 > From: Colin Woodbury > Date: Tue, 20 Dec 2022 09:41:51 +0900 > Subject: [PATCH 2/4] doc: add new SRFI-171 reducers to the manual > > --- > doc/ref/srfi-modules.texi | 96 +++++++++++++++++++++++++++++++++++++-- [...] > From 7b7538c61799fa0fa0e2fa18efba98b7de7da1ca Mon Sep 17 00:00:00 2001 > From: Colin Woodbury > Date: Wed, 21 Dec 2022 09:30:50 +0900 > Subject: [PATCH 3/4] srfi-171: add unit tests for new functions > > These tests mainly match the examples shown in the docs. > --- > test-suite/tests/srfi-171.test | 66 ++++++++++++++++++++++++++++++---- We=E2=80=99d squash these three commits together to provide a single self-contained commit with code and the corresponding tests and doc. The convention in Guile is for commit logs to follow the ChangeLog style (see =E2=80=98git log=E2=80=99 for examples). If you=E2=80=99re not sure h= ow to do that, I can do it on your behalf as a welcome present. ;-) > From 87a74d106f11680c4924befb664d7ef685c16b06 Mon Sep 17 00:00:00 2001 > From: Colin Woodbury > Date: Thu, 22 Dec 2022 20:32:33 +0900 > Subject: [PATCH 4/4] doc: added a guide for writing custom reducers > > The guide previously explained what reducers were, but not the specifics > of how to write them yourself. This commits rectifies this. Nice! > +++ b/doc/ref/srfi-modules.texi > @@ -5966,6 +5966,82 @@ Yield the maximum (or minimum) value of the transd= uction, or the > @var{seed} value if there is none. > @end deffn >=20=20 > +@subheading Writing your own reducers > +If you want to reduce some values via an ordinary function that you Please capitalize section titles and leave a blank line below it (same for the section that follows). > +However, if you want more customized behaviour (such as early > +termination and/or arbitrary manipulation of the input values) then > +you're free to write a reducer manually. To do so, we need to write a Normally we leave two spaces after end-of-sentence periods, to ease navigation in Emacs and please Texinfo (info "(texinfo) Ending a Sentence"). Could you send updated patches? Thanks for your work! Ludo=E2=80=99.