[Compose] 17. List comprehensions with Applicative Functors
List with 17 Compose
2023-09-14 08:59:15 时间
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([1,2,3])); 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" ]
相关文章
- Java 数组和List的使用「建议收藏」
- springmvc接收字符串转list
- Java list转为object_List集合转JSONObject
- C# List去重的三种方法「建议收藏」
- python之列表(list)
- c语言list嵌套遍历「建议收藏」
- java list 转json 字符串_fastjson将java list转为json字符串
- Linked List Cycle详解程序员
- list java中List对象通用排序算法详解编程语言
- Oracle 视图 V$MAP_COMP_LIST 官方解释,作用,如何使用详细说明
- Java遍历List集合的三种方法详解编程语言
- Java List.add()方法:向集合列表中添加对象
- 利用Redis实现List元素的排序(redis排序list)
- Redis中的List数据结构详解(redis中list数据)
- Redis如何清空List:技巧分享(redis清空list)
- 使用Redis在List中存储数据(redis存入list)
- Mysql实现List存储的技巧(mysql存储list)
- Oracle 中的 WITH 语句使用技巧(oracle with用法)
- 以List形式存储至Redis中(往redis里存list)
- 使用Redis实现List存储(向redis中存list)
- Redis中List与Set的应用(redis集合与list)
- Redis自带数据结构List(redis自带list)
- 将list转换为json失败的原因