Es6 Ncurry
17 February 2014
While reading through Highland Streams, I noticed how many
of the functional bits ES6 will help–as soon as we get them. One function I rather liked, ncurry
follows the basic curry
syntax but solves the “function.length problem” by passing n
, the
length, as the first parameter.
The important part internally works just like leave
(see
Take or Leave Functional Programming).
I rewrote the functions needed using ES6 notation; making heavy use of rest and spread operators. This
included an ES6-style rewrite of leave
.
I see one possible downside to this implementation. We can’t use this
when applying leave
’s function.
We have to use null
unless we add a receiver
parameter to the signature somewhere.
Try it in the repl
Try it in the repl