chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New egg: CHICKEN Transducers


From: siiky
Subject: Re: New egg: CHICKEN Transducers
Date: Thu, 5 Jan 2023 13:11:49 +0000

How about SRFI 42?

I wrote a little bit in #chicken but think it should be added here as well.


Pros of SRFI 42:

+ It's short and clear. It feels very natural to me. Maybe just because I've used it for some time while I've just been introduced to transducers now, but I have the impression that's not it.

Pros of transducers (the egg):

+ Seems to be more generic: the operation and the resulting data structure are decoupled. + Seems to be easier to implement/understand (based on the examples of the post): look at "Why this whole :dispatched business?" from the SRFI 42 doc[0] to compare with a `type-fold`, or the sample implementation[1].


There are some things I would still use SRFI 42 for, at least for now that I'm new to transducers. For example:

(list-ec (:list x lst1)
         (:list y lst2)
         (if (even? (* x y)))
         (cons x y))

Which is similar to (filter even (map * lst1 lst2)) but more performant because there's no intermediate list. I have no idea how to do this with transducers.


[0]: https://srfi.schemers.org/srfi-42/srfi-42.html
[1]: https://srfi.schemers.org/srfi-42/ec.scm





reply via email to

[Prev in Thread] Current Thread [Next in Thread]