Currying

Learn how to break down a function that takes multiple arguments into a series of functions that take only one argument.

What is currying?

Currying involves converting the function, combining multiple arguments into a series of functions that are executed one after another.

Whenever we feed it an argument, we can write a function that returns another function that also accepts an argument and returns a function. This continues to happen until the final argument is passed. When that happens, the code block executes. This is called currying, and it’s very popular in functional languages like Haskell and F#. The following code snippet is a boilerplate example of currying:

Get hands-on with 1200+ tech skills courses.