DEV Community

Andres Haro
Andres Haro

Posted on

Dynamic Reducer - Python

The reducer is a pure function that takes the current state and an action and returns the next state. Note that the state is accumulated as each action on the collection is applied to change this state. So given a collection of actions, the reducer is applied to each value of the collection (from left-to-right).

At this point, this is an example of how to do a dynamic reducer by using the following libraries "operator & reduce."

Top comments (1)

hedwardd profile image
Heath Daniel

This is actually super cool. Thanks for sharing, Andres!