Functional-Light-JS
Functional-Light-JS copied to clipboard
Chapter 9: Mismatch in map parameters.
In the Map section of Chapter 9, after the implementation of map you give a note on parameter order, the example given has the parameters in the wrong order.
map( ["1","2","3"], unary( parseInt ) );
// [1,2,3]
I believe it should be
map(unary( parseInt ), ["1","2","3"] );
// [1,2,3]
Please forgive me if I'm mistaken.
You're correct, thanks for catching that!
The parameter ordering mismatch is also echoed in the first example in Method Vs Standalone section. The current code is
[1,2,3,4,5]
.filter( isOdd )
.map( double )
.reduce( sum, 0 ); // 18
// vs.
reduce(
map(
filter( [1,2,3,4,5], isOdd ),
double
),
sum,
0
); // 18
I believe it should be
[1,2,3,4,5]
.filter( isOdd )
.map( double )
.reduce( sum, 0 ); // 18
// vs.
reduce(
sum,
0,
map(
double,
filter( isOdd, [1,2,3,4,5] )
)
); // 18
I realise that this is mostly to point out the difference in the API, which is why I didn't create a new Issue.