Last active
December 20, 2015 21:19
-
-
Save lu911/6197097 to your computer and use it in GitHub Desktop.
Stream
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Main { | |
def main(args: Array[String]): Unit = { | |
new StreamMethods() | |
} | |
} | |
class StreamMethods{ | |
val methods = List(streamTest) | |
def numsFrom(n : BigInt): Stream[BigInt] = n #:: numsFrom(n + 1) | |
def streamTest(): Unit = { | |
val tenOrMore = numsFrom(10) | |
println("Stream : " + tenOrMore) | |
println("Stream tail : " + tenOrMore.tail) | |
println("Stream take : " + tenOrMore.take(5)) | |
println("Stream take force : " + tenOrMore.take(5).force) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment