Currying Exercise Hints
jsbin.com/romun
First use a curried
mutliply
to create a double function. (double = multiply(2)
)Uses the Ramda library.
Show the first example, the
double
function:
var double = _.multiply(2);
console.log( double(13) );
Ramda automatically curries it. The first task (out of three) is to split words around spaces. Taking the
split(' ', 'a b')
example, but without having to provide the splitter argument (' '
)We can just do:
var words = _.split(' ')
And now just use words('a b')
for splitting.Note: if you already have a function that has been curried, you can just give some of the arguments it expects and it will work.
JavaScript has negative infinity if you need a really low number.
-Infinity