DEV Community

Andres Haro
Andres Haro

Posted on

2

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)

Collapse
 
hedwardd profile image
Heath Daniel

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

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay