chicken-users
[Top][All Lists]
Advanced

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

Re: New egg: CHICKEN Transducers


From: Jeremy Steward
Subject: Re: New egg: CHICKEN Transducers
Date: Thu, 5 Jan 2023 18:48:46 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.6.0

On 1/5/23 06:11, siiky wrote:
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.


I think the easiest way for this would be to just zip the list together:

    (transduce list-fold
               (compose
                 (zip-list lst2)
                 (filter (lambda (p)
                           (even? (* (car p) (cdr p))))))
               collect-list
               lst1)

Thoughts?
--
Jeremy Steward



reply via email to

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