[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: New egg: CHICKEN Transducers
From: |
Moritz Heidkamp |
Subject: |
Re: New egg: CHICKEN Transducers |
Date: |
Fri, 06 Jan 2023 14:38:24 +0100 |
Hi,
On 5 January 2023 18:48 -07, Jeremy Steward wrote:
> On 1/5/23 06:11, siiky wrote:
> 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)
FYI: Clojure's `sequence` function accepts varargs like `map` and also a
transducer which allows you to express this like so:
(sequence (comp (map *) (filter odd?)) lst1 lst2)
The docstring describes it like this:
> When a transducer is supplied, returns a lazy sequence of applications
> of the transform to the items in coll(s), i.e. to the set of first
> items of each coll, followed by the set of second items in each coll,
> until any one of the colls is exhausted. Any remaining items in other
> colls are ignored. The transform should accept number-of-colls
> arguments
I think you could offer the same API for `transduce`. Of course, you'll
have to adjust the `map` transducer accordingly, too.
Cheers
Moritz
- New egg: CHICKEN Transducers, Jeremy Steward, 2023/01/04
- Re: New egg: CHICKEN Transducers, Mario Domenech Goulart, 2023/01/05
- Re: New egg: CHICKEN Transducers, Peter Bex, 2023/01/05
- Re: New egg: CHICKEN Transducers, Chris Brannon, 2023/01/05
- Re: New egg: CHICKEN Transducers, siiky, 2023/01/05
- Re: New egg: CHICKEN Transducers, Jeremy Steward, 2023/01/05
- Re: New egg: CHICKEN Transducers,
Moritz Heidkamp <=
- Re: New egg: CHICKEN Transducers, siiky, 2023/01/06
- Re: New egg: CHICKEN Transducers, siiky, 2023/01/06
- Re: New egg: CHICKEN Transducers, siiky, 2023/01/09
- Re: New egg: CHICKEN Transducers, Jeremy Steward, 2023/01/10
Re: New egg: CHICKEN Transducers, Jeremy Steward, 2023/01/05
Re: New egg: CHICKEN Transducers, siiky, 2023/01/05
Re: New egg: CHICKEN Transducers, Walter Lewis, 2023/01/05