code-reviews 2020-09-11

@jeffparker has joined the channel

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?

πŸ‘ 1

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

πŸ‘ 1

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))

πŸ‘ 1

which only looks at values that have previous values

oh yeah that might be better, gotta think about that a bit

@ryan.zwiefelhofer has left the channel