Scala Range与Stream
程序员文章站
2022-05-15 19:22:20
...
一 Range
scala>1 to 10
res20: scala.collection.immutable.Range.Inclusive=Range1 to 10
scala>1 to 10 by 2
res21: scala.collection.immutable.Range= inexact Range1 to 10 by 2
scala>(1 to 10).toList
res22:List[Int]=List(1,2,3,4,5,6,7,8,9,10)
scala>1 until 10
res23: scala.collection.immutable.Range=Range1 until 10
二 Stream
- scala>1#::2 #::3 #::Stream.empty
res24: scala.collection.immutable.Stream[Int]=Stream(1,?)
scala> val stream =(1 to 100000).toStream
stream: scala.collection.immutable.Stream[Int]=Stream(1,?)
scala> stream.head
res25:Int=1
scala> stream.tail
res26: scala.collection.immutable.Stream[Int]=Stream(2,?)
上一篇: vue中class样式的设置
下一篇: 带鱼与什么相克?带鱼与挺多食物都相克的
推荐阅读
-
python中range()与xrange()用法分析
-
C#实现Stream与byte[]之间的转换实例教程
-
Stream.Write 与 StreamWriter.Write 的不同
-
ThinkPHP模板范围判断输出In标签与Range标签用法详解
-
ThinkPHP模板范围判断输出In标签与Range标签用法详解
-
asp.net下DataSet.WriteXml(String)与(Stream)的区别
-
Python for循环与range函数的使用详解
-
Node.js Stream ondata触发时机与顺序的探索
-
Scala中正则表达式以及与模式匹配结合(多种方式)
-
Python学习:for 循环 与 range()函数