add
that takes one argument and returns a function. By calling it, the returned function remembers the first argument from then on via the closure. Calling it with both arguments all at once is a bit of a pain, however, so we can use a special helper function called curry
to make defining and calling functions like this easier.curry
function defined in the Appendix A - Essential Function Support./r/g
is a regular expression that means match every letter 'r'. Read more about regular expressions if you like.)git clone https://github.com/MostlyAdequate/mostly-adequate-guide.git
), copy the code above and have a go at it in the REPL. The curry function, as well as actually anything defined in the appendixes, are available in the support/index.js
module.npm
:hasLetterR
, removeStringsWithoutRs
, and censored
.map
:allTheChildren
function would be with the uncurried map
from lodash (note the arguments are in a different order):map(getChildren)
inline. Same with sort
, filter
, and other higher order functions (a higher order function is a function that takes or returns a function).()
's for convenience.compose
.Hint: you can submit your solution by doingCtrl + Enter
in the embedded editor!
git clone [email protected]:MostlyAdequate/mostly-adequate-guide.git
)cd mostly-adequate-guide/exercises
)npm run ch04
)