Last active
September 7, 2021 21:39
Revisions
-
mkuklis revised this gist
Apr 5, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,7 +22,7 @@ var add = autocurry(function (a, b, c, d) { add(1)(2)(3)(4); // 10 var one = add(1); one(4, 5, 6); // 16 add(2)(3, 4)(5); // 14 -
mkuklis revised this gist
Apr 5, 2013 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,4 +25,8 @@ var one = add(1); one(4, 5, 6) // 16 add(2)(3, 4)(5); // 14 -
mkuklis revised this gist
Apr 2, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ function toArray(args) { function autocurry(fn) { var len = fn.length; var args = []; return function next() { args = args.concat(toArray(arguments)); return (args.length >= len) ? fn.apply(this, args.splice(0)) : -
mkuklis created this gist
Apr 2, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ function toArray(args) { return [].slice.call(args); } function autocurry(fn) { var len = fn.length; var args = []; return function next () { args = args.concat(toArray(arguments)); return (args.length >= len) ? fn.apply(this, args.splice(0)) : next; } } // usage var add = autocurry(function (a, b, c, d) { return a + b + c + d; }); add(1)(2)(3)(4); // 10 var one = add(1); one(4, 5, 6) // 16