code-reviews

2020-09-11T12:24:50.069Z

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
Ben Sless 2020-09-13T10:19:56.072900Z

map-prev looks a lot like reductions πŸ™‚

phronmophobic 2020-09-11T18:22:52.071100Z

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

phronmophobic 2020-09-11T18:27:07.071500Z

(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

2020-09-11T18:30:50.071700Z

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
phronmophobic 2020-09-11T18:32:25.072Z

but both seem useful

phronmophobic 2020-09-11T18:32:57.072200Z

based on the usage, not sure if it would be better to have map-prev act more like: (map f coll (rest coll))

πŸ‘ 1
phronmophobic 2020-09-11T18:33:35.072400Z

which only looks at values that have previous values

2020-09-11T18:42:45.072700Z

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