Created
September 2, 2016 06:54
-
-
Save dolvik/8551d356e418bbc96dd8ee15543bd3fd to your computer and use it in GitHub Desktop.
JS functional calc
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
var five = num(5); | |
var one = num(1); | |
console.log(five(plus(one()))); //6 | |
function plus(arg){ | |
return function(arg2){ | |
return arg + arg2; | |
} | |
} | |
function num(val){ | |
return function(func){ | |
if (func === undefined){ | |
return val; | |
} | |
return func(val); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment