63 points · by espeed · 11y ago · 36 comments
Transducers arise out of realizing that transformations between (possibly infinite) lists can be encoded as a "reducer transformations", "transducers". When you work in this encoding you automatically get lazy transformation (since everything goes through a function call) and the avoidance of intermediate data structures (since everything goes through a function call!).
Moreover, there's a neat property of this encoding, a CPS encoding, which is that function composition still "works", it just works "backwards".
- https://github.com/abingham/python-transducers
- http://www.slideshare.net/alinadolgikh/austin-bingham-transd...
- http://sixty-north.com/blog/series/understanding-transducers...
The last link is an 8 part blog series discussing transducers from first principles, and discussing their use (still in the context of Python).
It depends on the useful "foldl" library of reducers.
Isn't your Transduction the same as doing premap (or lmap from Profunctor)?
Rich Hickey wrote about them on Cognitect's blog a while back: http://blog.cognitect.com/blog/2014/8/6/transducers-are-comi...
The author refers to the test suite for examples: https://github.com/cognitect-labs/transducers-python/blob/ma...
I know that they are more complicated/powerful than that but I can't quite point that out precisely.
You can lug around the transformation itself as if it were an object, almost, separate from the data it's meant to transform.
it seems like a long-winded and not very clear way to write something you could just do with a function and a list comprehension