January 2020
Intermediate to advanced
470 pages
11h 13m
English
7.1. Sum as you will: The following sumMany() function does the job:
const sumMany = total => number => number === undefined ? total : sumMany(total + number);sumMany(2)(2)(9)(6)(0)(-3)(); // 16
7.2. Working stylishly: We can do currying by hand for applyStyle():
const applyStyle = style => string => `<${style}>${string}</${style}>`;
7.3. Currying by prototype: Basically, we are just transforming the curryByBind() version so that it uses this:
Function.prototype.curry = function() { return this.length === 0 ? this() : p => this.bind(this, p).curry();};
You could work in a similar fashion and provide a partial() method instead.
7.4. Uncurrying the currying: We can work in ...
Read now
Unlock full access