scala学习笔记:集合
scala> 1 to 10
res9: scala.collection.immutable.Range.Inclusive = Range(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
scala> List(1,2,3,4)
res10: List[Int] = List(1, 2, 3, 4)
scala> (1 to 10).map(_*3).filter(_%2==1).reduce(_+_)
res8: Int = 75
试一试map
scala> (1 to 9).map((0 to _))
res5: scala.collection.immutable.IndexedSeq[scala.collection.immutable.Range.Inclusive] = Vector(Range(0, 1), Range(0, 1, 2), Range(0, 1, 2, 3), Range(0, 1, 2, 3, 4), Range(0, 1, 2, 3, 4, 5), Range(0, 1, 2, 3, 4, 5, 6), Range(0, 1, 2, 3, 4, 5, 6, 7), Range(0, 1, 2, 3, 4, 5, 6, 7, 8), Range(0, 1, 2, 3, 4, 5, 6, 7, 8, 9))
scala> (1 to 9).flatMap((0 to _))
res6: scala.collection.immutable.IndexedSeq[Int] = Vector(0, 1, 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
+++++++++++++++++++++++++++++++++++++++++++
如本文存在任何侵权部分,请及时告知,我会第一时间删除!
转载本博客原创文章,请附上原文@cnblogs的网址!
QQ: 5854165 我的开源项目 欢迎大家一起交流编程架构技术&大数据技术! +++++++++++++++++++++++++++++++++++++++++++
如本文存在任何侵权部分,请及时告知,我会第一时间删除!
转载本博客原创文章,请附上原文@cnblogs的网址!
QQ: 5854165 我的开源项目 欢迎大家一起交流编程架构技术&大数据技术! +++++++++++++++++++++++++++++++++++++++++++