Functional Programming explained to my grandma

CCavalier
35.1K views

Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

Currying

Currying is one of the words you will hear the most when you start to work with functionnal programming. It is also one of the hardest to figure out.

*Definition: Currying is the technique of translating the evaluation of a function which takes multiple arguments into evaluating a sequence of functions, each with a single argument *

To keep it simple, we'll just focus on what currying is useful for. You have a function which takes many parameters. However, you may want to bind some parameters.

It improves code readability by partially applying some functions and giving names to specific uses.

Implement the multiply and multiplyByTwo

Let's try with a clear-cut example. The area function defined take two parameters. Let's implement the specific case of the circle area and square area.

Implement the area computation
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content