pointfree模式
- pointfree模式是结合compose组合函数、curr柯里化函数、一等公民函数的结果
- 简单示例
- pointfree模式可省略传递被处理参数,结合curr柯里化函数,延迟执行,并缓存预处理结果
- pointfree模式参数均在参数上,调用函数更加可控且灵活
var snakeCase = function (word) {
return word.toLowerCase().replace(/\s+/ig, '_');
};
var snakeCase = compose(replace(/\s+/ig, '_'), toLowerCase);
var initials = function (name) {
return name.split(' ').map(compose(toUpperCase, head)).join('. ');
};
var initials = compose(join('. '), map(compose(toUpperCase, head)), split(' '));
initials("hunter stockton thompson");