Transducers, Mappers and Reducers

424px-Signal_processing_system[1]

This is an advanced functional programming topic, but I want to summarize only a couple of important points

  • Map and Reduce

First of all, the rationale for reducers was to allow for more performant seq operations by being able to utilize multiple cores and such…

  • Transducers

If you know C# very well, you should have learnt that Linq is good way to introduce functional programming techniques and F#. For example compare reduce with aggregate… and start to familiarize with the accumulator value pair.

Ready?

Now this is a porting from JavaScript transducer to CSharp gist based on the .Net library.

The elegance of the transducer pattern is that transformers compose naturally to produce new transformers.  So we can chain as many transformers together as we like, and since we end up with one transformed reducer, we only iterate over the collection once. We don’t need to create intermediate copies of the data or iterate over it multiple times.

Advertisements

One thought on “Transducers, Mappers and Reducers

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s