2012-11-23 89 views

回答

7
x #:: xs 

返回

Stream.cons(x, xs) 

它返回一個元件的流X,接着爲一個流XS。

3

正如SHildebrandt所說,#::是Streams的cons運算符。

換句話說,#::是什麼流::是列表

val x = Stream(1,2,3,4)     //> x : scala.collection.immutable.Stream[Int] = Stream(1, ?) 
10#::x         //> res0: scala.collection.immutable.Stream[Int] = Stream(10, ?) 

val y = List(1,2,3,4)      //> y : List[Int] = List(1, 2, 3, 4) 
10::y          //> res1: List[Int] = List(10, 1, 2, 3, 4)