Fork me on GitHub
Logan Powell17:06:25

👋 Hello friends! I'm getting my feet wet with transducers + core.async, but have hit a snag and can't find any answers via the Googles... how might I (if it's even possible) pass an argument to a transducer - not a reducing function but a parameter arg - within a comp?

Logan Powell17:06:21

I got this to work before I tried to compose the stats-xform into the transducer, but I don't know how to pass in a second arg later, when using it as a channel xform


sequence is not a transducer

Logan Powell17:06:42

Hi @hiredman! I should pull that out... the xf-zip-census is a transducer... sorry...

Logan Powell17:06:59

from the previous commit


I transducer is, sort of definitionally, a function that takes a reducing function and returns a reducing function

Logan Powell17:06:11

Is there a way I can wrap it to pass a second arg in?


you create a function that returns a transducer instead

Logan Powell17:06:40

ah, ok, so anything that the transducer need to run has to be statically defined

Logan Powell17:06:05

I see, so wrap a transducer in another function


like map isn't a transducer, but (map f) is

Logan Powell17:06:40

ok, let me chew on that a bit... thank you as always!

Alex Miller (Clojure team)17:06:24

cat is the only example in core of a function that is a transducer itself (rather than a function that returns one)

Logan Powell17:06:30

I sent out some props to you in there 😉

Logan Powell17:06:33

btw, I'm not sure if I shared this before, but I posted a getting started guide based on your last help: and on medium:

Logan Powell17:06:05

Gotcha @alexmiller I'm struggling, but it's very satisfying to see it all come together when it does.

Logan Powell17:06:55

btw, @alexmiller I'm reading your book "Clojure Applied"! ❤️

Logan Powell17:06:47

ok, let me get back to it 🙂

Alex Miller (Clojure team)17:06:54

Great! If you like it, leave a review on Amazon :)

Logan Powell19:06:11

Any idea why the filter step in the composition is getting skipped?

Logan Powell19:06:47



that ->map in the name is odd, because the filter ensures that each value coming through is a map, which is different from turning something into a map

Logan Powell19:06:45

Yes, I'm trying to filter out all items that aren't of type PersistentArrayMap

Logan Powell19:06:50

All the transducers work in isolation, but it's weird that when I comp them, the two on the outside (not (filter map?)) work


there are things that are not PersistentArrayMap that are accepted by map?, and counting on that specific type is never a good idea

Logan Powell19:06:55

btw, @hiredman your advice helped alot to get me this far

Logan Powell20:06:11

I fixed it by changing the upstream transducer. Sorry for hogging the air!