Currying in JavaScript

Dustin Diaz has a nice entry on currying in JavaScript a technique used often in languages such as LISP, Perl, and many others. Dustin's curry implementation:
JAVASCRIPT:
  1. function curry (fn, scope) {
  2. var scope = scope || window;
  3. var args = [];
  4. for (var i=2, len = arguments.length; i <len; ++i) {
  5. args.push(arguments[i]);
  6. };
  7. return function() {
  8. fn.apply(scope, args);
  9. };
  10. }
This should look somewhat similar to Prototype bind and of course Dojo has dojo.lang.curry() which we mentioned awhile ago.

Zero. Zilch. Nada. None. No commento.

Feel free to leave related comments here!

Rather Leave A Voice Comment?

Feel free to leave voice comments here!

Social Bookmarking

del.icio.us:Currying in JavaScript digg:Currying in JavaScript spurl:Currying in JavaScript furl:Currying in JavaScript Y!:Currying in JavaScript

Leave a comment

The most recent replies are displayed at the top. Please comment accordingly. Your name and email are required. Track comments via RSS.

Next Generation Ecommerce Software & Web Store Platform > Fast, Simple, Friendly Stores
RSS
Stores  Features  Blog  Archives  About  Contact       © 2006 Web 2.0 Stores