January 2019
Beginner
210 pages
4h 47m
English
We have also learned that the functional composition only works with unary functions and that if we wish to compose functions, that are not unary, such as binary functions we can use function partial application to invoke one of the function with only some of its arguments and generate new functions that take the remaining arguments. Finally, we also learned that we can use currying to transform a given function into a function that can be partially applied:
function curry3<T1, T2, T3, T4>(fn: (a: T1, b: T2, c: T3) => T4) { return (a: T1) => (b: T2) => (c: T3) => fn(a, b, c);}const trim = (s: string) => s.trim();const capitalize = (s: string) => s.toUpperCase();const trimAndCapitalize = R.compose(trim, capitalize); ...Read now
Unlock full access