News for hackers. Stuff that matters.
Re:Clojure's Transducers are as fundamental as function comp... by moomin on Monday September 01, 2014 @03:44AM (#8251874)
Is this quite right? Sorry this is a bit vague/unclear, but what happens if you, say, call the reduction function, throw the result away and then call it again?

I ran this example through Clojure in let's write a transducer, and it plain doesn't work; I think the mapping given above works for all transducers that are actually valid, but I think the type definition allows for broken ones.

Again, I'm not sure & still learning, so please explain if I've gone wrong here.

Re:Clojure's Transducers are as fundamental as function comp... by tel on Monday September 01, 2014 @10:42AM (#8253061)
If you throw the result away in pure code then you may as well have never computed it: the second result holds only.

In an impure setting none of the math above holds.

Edit: note that this doesn't mean you have to throw away local or global state. You can recapture that by using state machine transformers or even Kleisli state machine transformers (although that gets pretty heavy!)

Re:Clojure's Transducers are as fundamental as function comp... by moomin on Thursday September 04, 2014 @05:31AM (#8267330)
Aaah. Makes sense. I couldn't figure out why the reasoning seemed sound, but I had something that didn't match. It's because in Clojure, r has state itself.