Last active
June 12, 2017 10:19
-
-
Save wuliupo/ace0f34c53f8f5e0afefbb4d06f672f0 to your computer and use it in GitHub Desktop.
Currying-柯里化
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
| /* | |
| Curry(咖喱) 的概念很简单:只传递给函数一部分参数来调用它,让它返回一个函数去处理剩下的参数。 | |
| - 柯里化: http://baike.baidu.com/view/2804134.htm | |
| - Currying: https://en.wikipedia.org/wiki/Currying | |
| - Lodash: https://lodash.com/docs#curry | |
| - Lodash-FP:https://github.com/lodash-archive/lodash-fp | |
| - Ramda:http://ramdajs.com/ | |
| */ | |
| function match(what) { | |
| return function(str){ | |
| str.match(what) | |
| }; | |
| }); | |
| var hasSpaces = match(/\s+/g); | |
| console.log(hasSpaces("hello world")); | |
| console.log(hasSpaces("tori_spelling")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment