Skip to content

Instantly share code, notes, and snippets.

@lu911
Last active December 20, 2015 21:19
Show Gist options
  • Save lu911/6197097 to your computer and use it in GitHub Desktop.
Save lu911/6197097 to your computer and use it in GitHub Desktop.
Stream
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