当前位置:网站首页>Kotlin combines flatmap for filtering and zip merge operators
Kotlin combines flatmap for filtering and zip merge operators
2022-07-07 08:15:00 【yu-Knight】
//Kotlin Combination of Chinese and Western Medicine flatMap Perform filtering operations and zip Merge operators
fun main() {
val list = listOf<String>(" Huang Xiaoming ", " Jet Li ", " Bruce Lee ", " Liu Jun ", " Li Si ", " Liu Ming ", " Liu Jun ", " Huangjiaju ", " huang feihong ")
val list2 = list.map {
"$it"
}
println(list2)
val newList = listOf(
listOf(" Huang Xiaoming ", " Jet Li ", " Bruce Lee "),
listOf(" Liu Jun ", " Li Si ", " Liu Ming "),
listOf(" Liu Jun ", " Huangjiaju ", " huang feihong ")
)
newList.flatMap { it ->
it.filter { it ->
it.contains(" yellow ") // Inside is true Just go back to ,false Just filter it out. Don't
}
}.map {
println("$it ")
}
/*******************************************/
val names = listOf(" Zhang San ", " Li Si ", " Wang Wu ")
val ages = listOf(12, 34, 22)
// principle : Put the first set and the second set , combined , Create a new collection and return
// Create a new collection ( Elements , Elements , Elements ) Elements Pair(K,V) K Replace the elements in the first set ,V Represents the elements in the second set
val zip: List<Pair<String, Int>> = names.zip(ages)
println(zip) //[( Zhang San , 12), ( Li Si , 34), ( Wang Wu , 22)]
}
边栏推荐
- Zcmu--1492: problem d (C language)
- WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after conne
- Codeforce c.strange test and acwing
- Leetcode simple question: find the K beauty value of a number
- Use of JMeter
- LeetCode简单题之字符串中最大的 3 位相同数字
- Niu Mei's mathematical problem --- combinatorial number
- 【数字IC验证快速入门】11、Verilog TestBench(VTB)入门
- [quick start of Digital IC Verification] 11. Introduction to Verilog testbench (VTB)
- 力扣(LeetCode)187. 重复的DNA序列(2022.07.06)
猜你喜欢
柯基数据通过Rainbond完成云原生改造,实现离线持续交付客户
[quick start of Digital IC Verification] 10. Verilog RTL design must know FIFO
拓维信息使用 Rainbond 的云原生落地实践
Excel import function of jeesite form page
在Rainbond中实现数据库结构自动化升级
Quick analysis of Intranet penetration helps the foreign trade management industry cope with a variety of challenges
Rainbond 5.6 版本发布,增加多种安装方式,优化拓扑图操作体验
解读创客思维与数学课程的实际运用
王爽 《汇编语言》之寄存器
Real time monitoring of dog walking and rope pulling AI recognition helps smart city
随机推荐
Réplication de vulnérabilité - désrialisation fastjson
LeetCode简单题之判断一个数的数字计数是否等于数位的值
Don't stop chasing the wind and the moon. Spring mountain is at the end of Pingwu
Lua 编程学习笔记
雅思考试自己的复习进度以及方法使用【日更版】
Zsh shell adds automatic completion and syntax highlighting
Notes on PHP penetration test topics
buureservewp(2)
Game attack and defense world reverse
在 Rainbond 中一键安装高可用 Nacos 集群
Uniapp mobile terminal forced update function
Register of assembly language by Wang Shuang
Example of file segmentation
漏洞复现-Fastjson 反序列化
船载雷达天线滑环的使用
探索STEAM艺术设计中的创造力
Pytoch (VI) -- model tuning tricks
offer收割机:两个长字符串数字相加求和(经典面试算法题)
ROS Bridge 笔记(05)— carla_ackermann_control 功能包(将Ackermann messages 转化为 CarlaEgoVehicleControl 消息)
利用 Helm 在各类 Kubernetes 中安装 Rainbond