Functional Programming – Currying

What is Currying

Currying is the process of taking a function that accepts N arguments and turning it into a chained series of N functions each taking 1 argument.

Any use cases or just another FP hype?

Many times, we call issue an ajax call and get a large array of objects in JSON returned like below:

To get the list of record ids, you can do:

But you may aware that the predicate function like this is very common. Then you may want to create a more reusable function to do that like below:

However, now you have add another parameter that is not able to be used in the map function as it just takes one parameter for the element in the array (ie. person in this example). With currying, you can now turn the 2 parameters function into 2 one-parameter function chain and get the job done below:

Take this a step further

We can create another function that is you can give it the list as well

Apply another function programming technique called composition, you can do the following:



Functional Programming – Currying

log in

Use demo/demo public access

reset password

Back to
log in
Choose A Format
Personality quiz
Trivia quiz