Created
June 13, 2014 08:51
-
-
Save Williammer/f6e63c860e4e07e977fc to your computer and use it in GitHub Desktop.
jsPattern.curryExample.js - one simple curry example to partially add parameters, with closure.
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 characters
| function add(x, y) { | |
| if (typeof y === "undefined") { // partial | |
| return function (y) { | |
| return x + y; | |
| }; | |
| } | |
| // full application | |
| return x + y; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment