January 2020
Intermediate to advanced
470 pages
11h 13m
English
Back in the Parsing numbers tacitly section of Chapter 5, Programming Declaratively – A Better Style, we saw that using parseInt() with reduce() would produce problems because of the unexpected arity of that function, which took more than one argument—remember the example from earlier?
["123.45", "-67.8", "90"].map(parseInt); // problem: parseInt isn't // monadic! // [123, NaN, NaN]
We have more than one way to solve this. In Chapter 5, Programming Declaratively – A Better Style, we went with an arrow function. This was a simple solution, with the added advantage of being clear to understand. In Chapter 7, Transforming Functions – Currying and Partial Application, we will look at yet another, based on partial application. ...
Read now
Unlock full access