Fork me on GitHub

How do people feel about these transducers I've been playing with: 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?

👍 3

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

👍 3

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

👍 3

which only looks at values that have previous values


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

Ben Sless10:09:56

map-prev looks a lot like reductions 🙂