getify / Functional-Light-JS

Pragmatic, balanced FP in JavaScript. @FLJSBook on twitter.
http://FLJSBook.com
Other
16.6k stars 1.96k forks source link

partialRight utility seems to have issue #196

Closed Etherum7 closed 4 years ago

Etherum7 commented 4 years ago

It is written

The value "z:last" is only applied to the z parameter in the case where f(..) is called with exactly two arguments (matching x and y parameters). In all other cases, the "z:last" will just be the rightmost argument, however many arguments precede it.

but when only one argument is passed as in the second example the "z:last" is not assigned to the right most arguments.

image

getify commented 4 years ago
f(1);  // 1 "z:last"

Here "z:last" is the "rightmost argument" (aka the "last argument").

Note that I didn't say "rightmost parameter". In a variadic-functions language, you are free to pass as few or as many arguments as you want no matter how many parameters are declared. This utility (as with pretty much all others) is applying its logic to the arguments, not the parameter; a function can't really pragmatically self-inspect its own definition to apply logic based on declared parameters.