Created
May 20, 2014 15:11
-
-
Save Shinpeim/57333375e27bb522d217 to your computer and use it in GitHub Desktop.
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 compose(f, g) { | |
| return function(x){ | |
| return g(f(x)); | |
| } | |
| } | |
| var increment = function(x) { | |
| return x + 1; | |
| } | |
| var decrement = function(x) { | |
| return x - 1; | |
| } | |
| // increment のあとに decrement する関数を作る | |
| var do_nothing = compose(increment, decrement); | |
| console.log(do_nothing(10)); // => 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment