Back
Close

Functional Programming explained to my grandma

Anne-Honyme
8,403 views

Currying

Currying is one of the words you will hear the most when you start to work with functional 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 *

We can see currying as a series of partial application.

For a function who has N parameters, a partial application will have N-X. It improves code readability by binding some parameters and giving names to specific uses.

Implement the area computation

Now we have seen what is partial application, we can introduce currying as a series of partial application, where at each step we only apply one parameter.

Example

Implement the multiply and multiplyByTwo
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants