From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Damien Mattei Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] Extensions for SRFI-171 (Transducers) Date: Thu, 22 Dec 2022 15:52:27 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000fcbe4d05f06bd1fc" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40388"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Thu Dec 22 15:53:33 2022 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 1p8Mwu-000AGA-Lm for guile-devel@m.gmane-mx.org; Thu, 22 Dec 2022 15:53:32 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8MwE-0004R3-CU; Thu, 22 Dec 2022 09:52:50 -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 1p8Mw7-0004PF-1Z for guile-devel@gnu.org; Thu, 22 Dec 2022 09:52:43 -0500 Original-Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p8Mw5-0003Qh-5e for guile-devel@gnu.org; Thu, 22 Dec 2022 09:52:42 -0500 Original-Received: by mail-ej1-x635.google.com with SMTP id gh17so5460687ejb.6 for ; Thu, 22 Dec 2022 06:52:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=vfveVnKopYEqQlahILyQ8qMFGNn11h4I4TW8gYHda6k=; b=OqEEYL32tOtkY/Kt1pHSBjrKqypg5WwA0lsQUJ5g0XYxHsdyhaUGeEjTIOeYAYNoOT +67sbH2cfJqVHSPeHQoW/cFJwRtwk28iiNkQf5PaF7/bH5OifGiArva3muHuwIcyCddI qnNSm6npwLRvMlxaBvPh4Uxicplr09cVdMiukBcCdRb2hJRMWV1DJtNkoi3aHI6664fU By6dGsfFxuS5kBoyJTZHpmfcsjkjiF0QdL9kTNoKxO+6raeoQoL2sPRk99+6ve85QdYk Gb0uU6jRzXFYbAsF3wRkp+4LBsc3CChk3A5cV5nB40b9tTElEnSk1toGd52CSVNBF0gE iIMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vfveVnKopYEqQlahILyQ8qMFGNn11h4I4TW8gYHda6k=; b=krwhiej8m2f3kT8uf0S8BqtICLD9cF/e8aGZPMdMxQPUmW6GE8JIYKiVmOCCDh8GIb DtUyJZqghVJ497SPW6EUeVgJf2Mn2Z6LhY24Zo5X+6/w/XFdtd+1EXkvLUFCpU34CRZu 24FgWqP5Sj/xMx6vW4cVClVMxfvaATjN5q8SqyNWCZx4s1RhAWAvjisJOJmUVY/8KR32 vkAa3H0NbSdTMl0oi78jbUXCJ0LlcDVVDVj4J7HJ/oRyvoP7U5llxGEzpYBgikMStZ79 7vDqLUa/Wo3IJfpNKkO1qTNpQOXhjiCk3PCpjqL1ngJ9YkhBimI8WMlG5tXBN/ip+Z/e hH+g== X-Gm-Message-State: AFqh2kqxvzH0lBSmIhtRTuhlPTkNfRAMORj628vYyEo5r1QzMKk+mBWy ilDpLW0vN3ol9wDRQTSKBHjHUHMcyvLabX1/5ho4u0QjShM33Q== X-Google-Smtp-Source: AMrXdXscayScqBqaOD1ai6ZLfGapN7E7FGR0sSg6KI46jzzx22RXuNXgKx2o/fOTdsTmIqWpdg3pPOHNJLULnpm5BJc= X-Received: by 2002:a17:906:f857:b0:835:57c9:6424 with SMTP id ks23-20020a170906f85700b0083557c96424mr768686ejb.529.1671720758720; Thu, 22 Dec 2022 06:52:38 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::635; envelope-from=damien.mattei@gmail.com; helo=mail-ej1-x635.google.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, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:21518 Archived-At: --000000000000fcbe4d05f06bd1fc Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable i just understood the scheme :-) scheme@(guile-user)> (list-transduce (compose (tfilter (=CE=BB (x) x)) (tdelete-duplicates)) rcons (list 1 2 #f 3 3 4)) $12 =3D (1 2 3 4) sorry... On Thu, Dec 22, 2022 at 3:33 PM Damien Mattei wrote: > hello, > just trying transducers before using it, i try to understand. > what is wrong with that: > scheme@(guile-user)> (list-transduce (tfilter (=CE=BB (x) x)) > (tdelete-duplicates) (list 1 2 #f 3 3 4)) > ice-9/boot-9.scm:1685:16: In procedure raise-exception: > Wrong number of arguments to # srfi/srfi-171.scm:338:2 (reducer)> > > Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. > > Regards, > Damien > > On Wed, Dec 21, 2022 at 11:01 AM Linus Bj=C3=B6rnstam < > linus.bjornstam@veryfast.biz> wrote: > >> As the author of both the SRFI and the guile code I am very happy you >> like it. I don't have a computer at the moment, but I looked through the >> code and it looked great. >> >> All additions should have been included in the original SRFI :) >> >> one comment: your code uses define-public, which the rest of SRFI-171 >> code does not. >> >> I am not in any position to sign code off for inclusion in guile proper, >> but if the define-public thing is fixed it very much has my blessing. >> >> Best regards >> Linus Bj=C3=B6rnstam >> >> On Wed, 21 Dec 2022, at 01:48, Colin Woodbury wrote: >> > Happy holidays everyone, I hope everything is going well for you. >> > >> > Since discovering SRFI-171 (Transducers) I have fallen in love with it= . >> > Transducers let me "talk the way I want to talk" while knowing that I'= m >> > being efficient underneath w.r.t. to iteration and allocation. In usin= g >> > Guile's implementation, I noticed a few common idioms missing that are >> > otherwise present in other languages, so I've added them in a series o= f >> > patches. I've been using these often for a number of weeks without >> > issue, but of course have added unit tests as well. >> > >> > The full details are in the commit messages, but here are the main >> highlights: >> > >> > * rfold: The fundamental reducer. This allows the user to turn any >> > two-arg function into a valid reducer, so that they don't need to worr= y >> > about hand-writing reducers via case-lambda. >> > * rfind: Yields the first item in the transduction that matches some >> > predicate. Nice for locating some specific value from a potentially >> > large data source (e.g. a port). >> > * twindow: Like tsegment, but yields overlapping slices into the data= . >> > Cheers, and have a great holiday. >> > >> > Colin >> > >> > Attachments: >> > * 0001-srfi-171-add-twindow-and-various-reducers.patch >> > * 0002-doc-add-new-SRFI-171-reducers-to-the-manual.patch >> > * 0003-srfi-171-add-unit-tests-for-new-functions.patch >> >> --000000000000fcbe4d05f06bd1fc Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
i j= ust understood the scheme :-)

scheme@(guile-user)> (list-transduce (compose (tfilter (=CE=BB (x) = x)) (tdelete-duplicates)) rcons (list 1 2 #f 3 3 4))
$12 =3D (1 2 3 4)

sorry...


On Thu, Dec 22, 2022= at 3:33 PM Damien Mattei <da= mien.mattei@gmail.com> wrote:
hello,
just trying transducers before using it, i try to understand= .
what is wrong= with that:
sch= eme@(guile-user)> (list-transduce (tfilter (=CE=BB (x) x)) (tdelete-dupl= icates) (list 1 2 #f 3 3 4))
ice-9/boot-9.scm:1685:16: In procedure rais= e-exception:
Wrong number of arguments to #<procedure 10786aa60 at sr= fi/srfi-171.scm:338:2 (reducer)>

Entering a new prompt.=C2=A0 Typ= e `,bt' for a backtrace or `,q' to continue.

Regards,
Damien

=
On Wed, Dec 21, 2022 at 11:01 AM Linu= s Bj=C3=B6rnstam <linus.bjornstam@veryfast.biz> wrote:
As the author of both the SRFI and = the guile code I am very happy you like it. I don't have a computer at = the moment, but I looked through the code and it looked great.

All additions should have been included in the original SRFI :)

one comment: your code uses define-public, which the rest of SRFI-171 code = does not.

I am not in any position to sign code off for inclusion in guile proper, bu= t if the define-public thing is fixed it very much has my blessing.

Best regards
=C2=A0 Linus Bj=C3=B6rnstam

On Wed, 21 Dec 2022, at 01:48, Colin Woodbury wrote:
> Happy holidays everyone, I hope everything is going well for you.
>
> Since discovering SRFI-171 (Transducers) I have fallen in love with it= .
> Transducers let me "talk the way I want to talk" while knowi= ng that I'm
> being efficient underneath w.r.t. to iteration and allocation. In usin= g
> Guile's implementation, I noticed a few common idioms missing that= are
> otherwise present in other languages, so I've added them in a seri= es of
> patches. I've been using these often for a number of weeks without=
> issue, but of course have added unit tests as well.
>
> The full details are in the commit messages, but here are the main hig= hlights:
>
>=C2=A0 * rfold: The fundamental reducer. This allows the user to turn a= ny
> two-arg function into a valid reducer, so that they don't need to = worry
> about hand-writing reducers via case-lambda.
>=C2=A0 * rfind: Yields the first item in the transduction that matches = some
> predicate. Nice for locating some specific value from a potentially > large data source (e.g. a port).
>=C2=A0 * twindow: Like tsegment, but yields overlapping slices into the= data.
> Cheers, and have a great holiday.
>
> Colin
>
> Attachments:
> * 0001-srfi-171-add-twindow-and-various-reducers.patch
> * 0002-doc-add-new-SRFI-171-reducers-to-the-manual.patch
> * 0003-srfi-171-add-unit-tests-for-new-functions.patch

--000000000000fcbe4d05f06bd1fc--