The default behaviour of Array.map is unintuitive given that it returns the index and the original array as the second and third arguments to the callback function respectively.
I would approach the parseInt problem by writing a map function that takes two args, supplied one at a time (to facilitate partial application).
the first arg, a function f that will be supplied only one value at a time, that is, the current iterated value
the second arg, a 1-dimensional array of values to apply the function f on
It may appear complicated seeing it for the first time, but come back to the example and mull it over and it will start to click.
The default behaviour of
Array.mapis unintuitive given that it returns the index and the original array as the second and third arguments to the callback function respectively.I would approach the
parseIntproblem by writing a map function that takes two args, supplied one at a time (to facilitate partial application).fthat will be supplied only one value at a time, that is, the current iterated valuefonIt may appear complicated seeing it for the first time, but come back to the example and mull it over and it will start to click.
But why include
indexandoriginalArrayparameters when you don't use them?For that matter, why not make this point-free?
(... and around in circles we go!)
That's true, they are superfluous - I left those other args there to make it clearer how the args are moving around.