|
Scala 2
|
class
Stream
[ a ]
extends
java.lang.Object with
Seq with
ScalaObjectThe class Stream
implements lazy lists where elements
are only evaluated when they are needed. Here is an example:
object Main with Application { def from(n: Int): Stream[Int] = Stream.cons(n, from(n + 1)); def sieve(s: Stream[Int]): Stream[Int] = Stream.cons(s.head, sieve(s.tail filter { x => x % s.head != 0 })); def primes = sieve(from(2)); primes take 10 print }
Def Summary | |
def
append
[ a <: b ]
( rest : scala.<byname> )
: Stream
|
|
def
apply
( n : scala.Int )
: a
|
|
def
at
( n : scala.Int )
: a
|
|
override
|
def
copyToArray
[ a <: b ]
( xs : Array , start : scala.Int )
: Array
|
override
|
def
drop
( n : scala.Int )
: Stream
|
def
dropWhile
( p : Function1 )
: Stream
|
|
def
elements
: Iterator
|
|
override
|
def
exists
( p : Function1 )
: scala.Boolean
|
def
filter
( p : Function1 )
: Stream
|
|
def
flatMap
[ b ]
( f : Function1 )
: Stream
|
|
override
|
def
foldLeft
[ b ]
( z : b ) ( f : Function2 )
: b
|
override
|
def
foldRight
[ b ]
( z : b ) ( f : Function2 )
: b
|
override
|
def
forall
( p : Function1 )
: scala.Boolean
|
override
|
def
foreach
( f : Function1 )
: scala.Unit
|
def
head
: a
|
|
def
init
: Stream
|
|
def
isEmpty
: scala.Boolean
|
|
def
last
: a
|
|
def
length
: scala.Int
|
|
def
map
[ b ]
( f : Function1 )
: Stream
|
|
def
print
: scala.Unit
|
|
def
printElems
( buf : java.lang.StringBuffer , prefix : java.lang.String )
: java.lang.StringBuffer
|
|
def
reduceLeft
[ a <: b ]
( f : Function2 )
: b
|
|
def
reduceRight
[ a <: b ]
( f : Function2 )
: b
|
|
def
reverse
: Stream
|
|
def
tail
: Stream
|
|
override
|
def
take
( n : scala.Int )
: Stream
|
def
takeWhile
( p : Function1 )
: Stream
|
|
override
|
def
toString
: java.lang.String
|
def
zip
[ b ]
( that : Stream )
: Stream
|
Def Detail |
def
append
[ a <: b ]( rest : scala.<byname> ) : Stream
def
apply
( n : scala.Int ) : a
def
at
( n : scala.Int ) : a
def
copyToArray
[ a <: b ]( xs : Array , start : scala.Int ) : Array
def
drop
( n : scala.Int ) : Stream
def
dropWhile
( p : Function1 ) : Stream
def
elements
: Iterator
def
exists
( p : Function1 ) : scala.Boolean
def
filter
( p : Function1 ) : Stream
def
flatMap
[ b ]( f : Function1 ) : Stream
def
foldLeft
[ b ]( z : b ) ( f : Function2 ) : b
def
foldRight
[ b ]( z : b ) ( f : Function2 ) : b
def
forall
( p : Function1 ) : scala.Boolean
def
foreach
( f : Function1 ) : scala.Unit
def
head
: a
def
init
: Stream
def
isEmpty
: scala.Boolean
def
last
: a
def
length
: scala.Int
def
map
[ b ]( f : Function1 ) : Stream
def
print
: scala.Unit
def
printElems
( buf : java.lang.StringBuffer , prefix : java.lang.String ) : java.lang.StringBuffer
def
reduceLeft
[ a <: b ]( f : Function2 ) : b
def
reduceRight
[ a <: b ]( f : Function2 ) : b
def
reverse
: Stream
def
tail
: Stream
def
take
( n : scala.Int ) : Stream
def
takeWhile
( p : Function1 ) : Stream
def
toString
: java.lang.String
def
zip
[ b ]( that : Stream ) : Stream