We annihilate the need for the ol' nested for loop using Applicatives.

For example we have this kind of nested loop code:

for(x in xs){
for(x in ys){
for(z in zs){ }
}
}

We can refactor it by using List comprehension:

const {List} = Immutable;
const res1 = List.of(x => x).ap(List([,,]));
console.log(res1) // List [ 1,2,3 ]
const res1 = List.of(x => y=> `${x} - ${y}`)
.ap(List(['teeshirt', 'sweater']))
.ap(List(['large', 'medium', 'small']));
console.log(res1) //List [ "teeshirt - large", "teeshirt - medium", "teeshirt - small", "sweater - large", "sweater - medium", "sweater - small" ]

最新文章

  1. testng 6.8.6 eclipse plugin
  2. vim插件ctags的安装和使用
  3. MVC – 5.MVC设计模式和.NetMVC框架
  4. Java序列化中的serialVersionUID有什么用?
  5. String equals的技巧
  6. 【形式化方法:VDM++系列】2.VDMTools环境的搭建
  7. Mysql engine
  8. linux 双网关双IP设置
  9. Python 基础 字符串拼接 + if while for循环
  10. 文件上传下载样式 --- bootstrap
  11. 意外发现的大批量导入数据SqlBulkCopy类
  12. mybatis mapper.xml 写关联查询 运用 resultmap 结果集中 用 association 关联其他表 并且 用 association 的 select 查询值 报错 java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for mybatis.map
  13. Java---SSH(MVC)面试题
  14. 排序算法(sorting)
  15. [Linux] Linux Shell查找文件
  16. Cookie/Session机制详解(转载)
  17. [osg]osg背景图设置
  18. C++ 的那些坑 (Day 2)
  19. DevOps之技能面
  20. HiveSql调优经验

热门文章

  1. SQL2:数据操作
  2. 在IIS上运行node
  3. log4j log for java
  4. ESXI 5.5卡在LSI_MR3.V00
  5. 【BZOJ 3527】 3527: [Zjoi2014]力 (FFT)
  6. HDU 1011 Starship Troopers 树形+背包dp
  7. java--由一道选择题研究数值越界
  8. 20162328WJH实验五网络编程与安全实验报告
  9. java验证openssl生成的ssl证书和私钥是否匹配
  10. Unity 的一些特性