How do people feel about these transducers I've been playing with: https://gist.github.com/jjttjj/4e4572a1e57b0b59db2e3e554a272c12
The idea is to be able to aggregate values on a stream. is it bad to just use map
with some closed over state like this?
map-prev
looks a lot like reductions
π
both seem fine in principle. i think the implementation doesnβt adhere to transducer rules since state is created when you call map-prev instead of when itβs connected to a process
(def step (map-prev vec))
you're supposed to be able to reuse step
, but the way it's currently written would reuse the same state
Oh yeah, that makes sense, so I guess that shortcut doesn't work and I need to actually put the state inside the outermost transducer function
but both seem useful
based on the usage, not sure if it would be better to have map-prev
act more like:
(map f coll (rest coll))
which only looks at values that have previous values
oh yeah that might be better, gotta think about that a bit