Skip to content

Commit

Permalink
Changed Function.curry so that once an argument
Browse files Browse the repository at this point in the history
has been supplied it cannot be replaced.
  • Loading branch information
swannodette committed Nov 9, 2009
1 parent 153772b commit 0d0d83c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions FuncTools.js
Expand Up @@ -327,7 +327,7 @@ Function.implement({
/*
Function: Function.curry
A much more powerful version of currying. Any argument may
supplied.
supplied. Once an argument has been supplied it cannot be changed.
(start code)
var _ = Function._;
Expand All @@ -341,15 +341,15 @@ Function.implement({
return strA + strB;
}
var fn = append.curry(Function._, '!');
['Zap', 'Pow', 'Boom', 'Blast', 'Kerzow'].each(fn);
['Zap', 'Pow', 'Boom', 'Blast', 'Kerzow'].each(fn.decorate(Function.limit(1)));
(end)
*/
curry: function(bind) {
var self = this, arglist = Function.arglist(this), args = $A(arguments).rest();
if(args.length > arglist.length) args = args.drop(args.length - arglist.length);
args = argmerge($repeat(arglist.length, Function._), args);
return function curryFn() {
var fargs = argmerge(args, $A(arguments));
var fargs = argmerge($A(arguments), args);
if(curryFn.called) console.log(curryFn.caller.toString());
if(fargs.length > arglist.length) fargs = fargs.drop(fargs.length - arglist.length);
if(fargs.length >= arglist.length && fargs.every(Function.not(Function.eq(Function._)))) {
Expand Down

0 comments on commit 0d0d83c

Please sign in to comment.