Naming things is hard and arguments in generic utility functions are no exception. Making functions "tacit" or "point free" removes the need for the extra parameter names and can make your code cleaner and more succinct. In this lesson, we'll create a normal, "pointed" function and then use ramda's useWith function to refactor our way to point-free bliss.

const R = require('ramda');

const { find, useWith, identity, propEq } = R;

const countries = [
{flag: 'GB', cc: 'GB'},
{flag: 'US', cc: 'US'},
{flag: 'CA', cc: 'CA'},
{flag: 'FR', cc: 'FR'}
]; // Normally when you see there are multi args, you can think to use 'R.useWith'
// to make it point free style
//const getCountry = (cc, list) => find(propEq('cc'), list); /*
* Refactor the getCountry function to make it as point-free function
* */
const getCountry = useWith(
find,
[
propEq('cc'),
identity
]
); const result = getCountry('US', countries); console.log(result);

最新文章

  1. Linux环境搭建-在虚拟机中安装Centos7.0
  2. LInux升级Python版本2.7.11所遇问题汇总
  3. axis2打包方式发布
  4. 【浅层优化实战】ssh远程登录Linux卡慢的全过程排查及解决方案
  5. R(七): R开发实例-map热力图
  6. Memcache的部署和使用
  7. linux 入侵检查转载
  8. bzoj1753 [Usaco2005 qua]Who's in the Middle
  9. Android---两个视图间的淡入淡出
  10. php的开发的apache的配置及伪静态的应用
  11. 2018-2019-2 20165234 《网络对抗技术》 Exp1 PC平台逆向破解
  12. js 判断浏览器型号
  13. PB的一些记录
  14. 20165215 2017-2018-2 《Java程序设计》第5周学习总结
  15. Codeforces Round #439 (Div. 2) Problem A (Codeforces 869A) - 暴力
  16. [x] 封装、继承,多态
  17. RDD、DataFrame、Dataset
  18. object.prototype.call
  19. 虚拟机中CentoOs配置ip且连网
  20. 最近遇到的bug

热门文章

  1. 查看网站使用何种框架或者技术的插件——Wappalyzer
  2. 【Educational Codeforces Round 33 A】Chess For Three
  3. MyCat中间件:读写分离(转)
  4. COdeVS——T 1082 线段树练习 3 (分块练习)
  5. 【BZOJ 1146】【CTSC 2008】网络管理network
  6. [Spark源代码剖析] DAGScheduler划分stage
  7. SpringMVC,采用的是SpringJDBC
  8. Oracle 中的Interger类型
  9. Web--CSS控制页面(link与import方式差别)
  10. 《从零開始学Swift》学习笔记(Day 63)——Cocoa Touch设计模式及应用之单例模式