unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Damien Mattei <damien.mattei@gmail.com>
To: guile-devel@gnu.org
Subject: Re: [PATCH] Extensions for SRFI-171 (Transducers)
Date: Thu, 22 Dec 2022 18:32:55 +0100	[thread overview]
Message-ID: <CADEOaddYGBGt03uS-QZLo==Xvoq2xygx_7KcAjUWfLXQOtVjqQ@mail.gmail.com> (raw)
In-Reply-To: <CADEOadeF+kaOoQe6s6gnHa6V7e2YDQjLyNw9hSfooMqw4mj5OQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3884 bytes --]

i'm interested with transducers to speed up code:

;; 8'21" MacOS Ventura M1
  {unified-minterms-set-2 <+ (filter (λ (x) x) unified-minterms-set-1)} ;;
remove #f results
  (nodebug
   {unified-minterms-set-2-length <+ (length unified-minterms-set-2)}
   (dv unified-minterms-set-2-length))

  {unified-minterms-set <+ (remove-duplicates unified-minterms-set-2)}
;;(remove-duplicates-sorted unified-minterms-set-2)} ;; uniq MODIF
  (nodebug
   {unified-minterms-set-uniq-length <+ (length unified-minterms-set)}
   (dv unified-minterms-set-uniq-length))

with transducers:
;; 7'08" MacOS Ventura M1
  {unified-minterms-set <+ (list-transduce (compose (tfilter (λ (x) x))
(tdelete-duplicates)) rcons unified-minterms-set-1)}

it is an interesting 15% speed up in my code.


On Thu, Dec 22, 2022 at 3:52 PM Damien Mattei <damien.mattei@gmail.com>
wrote:

> i just understood the scheme :-)
>
> scheme@(guile-user)> (list-transduce (compose (tfilter (λ (x) x))
> (tdelete-duplicates)) rcons (list 1 2 #f 3 3 4))
> $12 = (1 2 3 4)
>
> sorry...
>
>
> On Thu, Dec 22, 2022 at 3:33 PM Damien Mattei <damien.mattei@gmail.com>
> wrote:
>
>> hello,
>> just trying transducers before using it, i try to understand.
>> what is wrong with that:
>> scheme@(guile-user)> (list-transduce (tfilter (λ (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 #<procedure 10786aa60 at
>> 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örnstam <
>> 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örnstam
>>>
>>> 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
>>> using
>>> > 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
>>> 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
>>> 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
>>> worry
>>> > 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
>>>
>>>

[-- Attachment #2: Type: text/html, Size: 6119 bytes --]

  reply	other threads:[~2022-12-22 17:32 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-21  0:48 [PATCH] Extensions for SRFI-171 (Transducers) Colin Woodbury
2022-12-21 10:00 ` Linus Björnstam
2022-12-22 14:33   ` Damien Mattei
2022-12-22 14:52     ` Damien Mattei
2022-12-22 17:32       ` Damien Mattei [this message]
2022-12-24 13:25         ` Damien Mattei
2022-12-24 15:28   ` [PATCHv2] " Colin Woodbury
2023-01-14 15:09     ` Ludovic Courtès
2023-01-21  1:48       ` [PATCHv3] " Colin Woodbury
2023-01-23 22:17         ` Ludovic Courtès
2023-01-24  0:21           ` Colin Woodbury
2023-01-24  9:07             ` Ludovic Courtès
2023-05-18  0:36               ` Colin Woodbury
2023-06-28 12:27                 ` Colin Woodbury
2023-08-12 19:37                   ` Linus Björnstam
2023-08-13  4:07                     ` Colin Woodbury
2023-08-18 10:03                   ` Ludovic Courtès
2023-08-18 10:10                     ` Colin Woodbury
2023-08-18 13:24                       ` Ludovic Courtès

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='CADEOaddYGBGt03uS-QZLo==Xvoq2xygx_7KcAjUWfLXQOtVjqQ@mail.gmail.com' \
    --to=damien.mattei@gmail.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).