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