当前位置:网站首页>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)]
}边栏推荐
- The largest 3 same digits in the string of leetcode simple question
- Rainbond 5.7.1 支持对接多家公有云和集群异常报警
- Application of slip ring of shipborne radar antenna
- 利用 Helm 在各类 Kubernetes 中安装 Rainbond
- The simple problem of leetcode is to judge whether the number count of a number is equal to the value of the number
- 积分商城管理系统中应包含的四大项
- Network learning (I) -- basic model learning
- Réplication de vulnérabilité - désrialisation fastjson
- Rainbond结合NeuVector实践容器安全管理
- 漏洞複現-Fastjson 反序列化
猜你喜欢

利用 Helm 在各类 Kubernetes 中安装 Rainbond

JS cross browser parsing XML application
![[quick start of Digital IC Verification] 12. Introduction to SystemVerilog testbench (svtb)](/img/dc/a809f2ec5f9e85a02e68c88bdcdb5e.png)
[quick start of Digital IC Verification] 12. Introduction to SystemVerilog testbench (svtb)

eBPF Cilium实战(1) - 基于团队的网络隔离

Empire CMS collection Empire template program general

JS quick start (I)

Jmeter 的使用

opencv学习笔记四——膨胀/腐蚀/开运算/闭运算

轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷

eBPF Cilium实战(2) - 底层网络可观测性
随机推荐
CTF-WEB shrine模板注入nmap的基本使用
青龙面板--整理能用脚本
Notes on PHP penetration test topics
快解析内网穿透助力外贸管理行业应对多种挑战
Complex network modeling (II)
Game attack and defense world reverse
Blob object introduction
Avatary's livedriver trial experience
拓维信息使用 Rainbond 的云原生落地实践
Zcmu--1492: problem d (C language)
buureservewp(2)
Lua 编程学习笔记
追风赶月莫停留,平芜尽处是春山
在Rainbond中实现数据库结构自动化升级
数据库实时同步利器——CDC(变化数据捕获技术)
青龙面板-今日头条
Four items that should be included in the management system of integral mall
Recursive method constructs binary tree from middle order and post order traversal sequence
Relevant data of current limiting
央视太暖心了,手把手教你写HR最喜欢的简历