In this article i will discuss about:
Higher Order Function
Higher-order functions are regular functions that do one or both of the following:
Takes one or many functions as arguments
Returns a function
Let’s look at simple example.
const c = b => b ;
add(a,b) => a+b; // here b is a function
A curried function is a function which takes multiple parameters one at a time, by taking the first argument, and returning a series of functions which each take the next argument until all the parameters have been fixed, and the function application can complete, at which point, the resulting value is returned.
const add = a => b => a + b;
const result = add(2)(3); // 5
Curried functions are particularly useful in the context of function composition.
In terms of algebra :
g: a -> b
f: b -> c
h: a -> c
h = f . g = f(g(x))
// Algebra definition, borrowing the
const g = n => n + 1;
const f = n => n * 2;
const h = x => f(g(x));
h(2); // 6
A social network 100% devoted to making you a better coder?
Level up every day