Skip to content

Instantly share code, notes, and snippets.

@wuliupo
Last active June 12, 2017 10:19
Show Gist options
  • Select an option

  • Save wuliupo/ace0f34c53f8f5e0afefbb4d06f672f0 to your computer and use it in GitHub Desktop.

Select an option

Save wuliupo/ace0f34c53f8f5e0afefbb4d06f672f0 to your computer and use it in GitHub Desktop.
Currying-柯里化
/*
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