JavaScript函数式编程之pointfree与声明式编程
更多相关内容见博客 github.com/zhuanyongxi… 函数式编程中的pointfree的意思就是“无参”或“无值”,pointfree style是一种编程范式,也作tacit programming,就是“无参编程”的意思了。什么是“无参编程”? // 这就是有参的,因为有word var snakeCase = word => word.toLowerCase().replace(/\s+/ig, '_'); // 这是pointfree var snakeCase = compose(replace(/\s+/ig, '_'), toLowerCase); 从另一个角度看,有参的函数的目的是得到一个数据,而pointfree的函数的目的是得到另一个函数。 所以,如下的方程,虽然也有参,也可以认为是pointfree的。 const titlesForYear = year => pipe( filter(publishedInYear(year)), map(book => book.title) ) 那这pointfree有什么用? 它可以让我们...