第22节:Scala集合和高级函数操作
来源:互联网 发布:英雄传奇刷点卷软件 编辑:程序博客网 时间:2024/06/10 17:49
scala> (1 to 10)
res0: scala.collection.immutable.Range.Inclusive = Range(1, 2, 3, 4, 5, 6, 7, 8,
9, 10)
scala> (1 to 10).re
<console>:8: error: value re is not a member of scala.collection.immutable.Range
.Inclusive
(1 to 10).re
^
scala> (1 to 10).re<console>:1: error: ';' expected but ')' found.
10)
^
res2: scala.collection.immutable.Range.Inclusive = Range(1, 2, 3, 4, 5, 6, 7, 8,
9, 10)
^
scala> (1 to 10).re<console>:1: error: ';' expected but ')' found.
10)
^
<console>:8: error: value re is not a member of scala.collection.immutable.Range
.Inclusive
(1 to 10).re
^
scala> (1 to 10).
| re
<console>:9: error: value re is not a member of scala.collection.immutable.Range
.Inclusive
possible cause: maybe a semicolon is missing before `value re'?
re
^
scala> (1 to 10).reduceLeft(_ - _)
res6: Int = -53
scala> (1 to 5).reduceLeft(_ - _)
res7: Int = -13
scala> (1 to 5).reduceLeft((a,b) => a-b)
res8: Int = -13
scala> (1 to 5).reduceLeft((a,b) => a)
res9: Int = 1
scala> (1 to 5).reduceLeft((a,b) => b)
res10: Int = 5
^
scala> (1 to 5).reduceLeft((a,b) => {println(a + " : "+ b ); a-b })
1 : 2
-1 : 3
-4 : 4
-8 : 5
res13: Int = -13
scala> (1 to 5).reduceLeft((a,b) => {println(a + " : "+ b ); a-b })
1 : 2
-1 : 3
-4 : 4
-8 : 5
res14: Int = -13
scala> (1 to 5).reduceRight((a,b) => {println(a + " : "+ b ); a-b })
4 : 5
3 : -1
2 : 4
1 : -2
res15: Int = 3
- 第22节:Scala集合和高级函数操作
- 第22课: Scala集合和高级函数操作实战及Spark源码鉴赏
- 大数据Spark “蘑菇云”行动前传第22课:Scala集合和高级函数操作实战及Spark源码鉴赏.
- scala简要:高级函数和高级类型
- 高级函数(分组排序和集合操作)
- 第8节:scala常用集合Map和Tuple
- scala中的数组和集合操作
- 第21节:Scala文件和xml操作(上)
- 第14节:scala编程之集合
- Spark 高级分析:第二章第1节Scala和数据科学家
- Scala集合操作指南
- Scala集合一些操作
- Scala数据集合操作
- scala集合操作
- Scala集合操作
- Scala 集合数组操作
- scala集合操作
- scala集合数据操作
- Java for Web学习笔记(五一):Log(3)代码中使用log4j2
- 1.线程安全
- 图形学基础之画心形和圣诞树
- Android Wear书签
- 信号---信号的产生
- 第22节:Scala集合和高级函数操作
- linux中nginx配置https
- 训练营结业作业
- Linux MySQL常见问题小结 FAQ
- pip初相识
- LeetCode 107. Binary Tree Level Order Traversal II
- 字符串转换成数字的方法【C#】
- 如何修复损坏的MySQL数据表
- Linux内核分析(九)——总结篇