January 2019
Beginner
210 pages
4h 47m
English
Currying is a functional programming technique that allows us to partially apply a function without having to worry about the way in which we implement our functions. Currying is the process of taking a function that takes multiple arguments and transforming it into a chain of unary functions. The following function allows us to transform a function, fn, which takes two arguments, a and b, into a function that takes one argument, a, and returns another function that takes one argument, b:
function curry2<T1, T2, T3>(fn: (a: T1, b: T2) => T3) { return (a: T1) => (b: T2) => fn(a, b);}
The above function is a higher-order function that allows our functions to be partially applied while keeping their implementation agnostic of this concern. ...
Read now
Unlock full access