dipping into wu.js: autoCurry

It’s my pleasure to welcome our first guest blogger: Nick Fitzgerald is the author of the excellent wu.js “a lazy functional programming library”. It’s an inspiring resource with a lot of really original touches and very nicely written. Take it away Nick….

One of my favorite functions in my newly released wu.js library is wu.autoCurry, a function that takes a function and returns (you guessed it) a curry-able version of that function.

I am going to assume you are familiar with currying from here on out. If you aren’t yet, check out the Wikipedia article on currying for a general overview, and Angus’ piece on currying in Javascript for a detailed explanation in our current language.

Some languages, notably Haskell, automatically provide currying to the user. If you don’t pass all the arguments to a function, it is implied that a new function that will take the rest is returned. In Javascript, we don’t have that luxury. We are forced to write explicit, boilerplate code every time we want to curry a function.

Continue reading