Skip to content

Instantly share code, notes, and snippets.

@itang
Created July 13, 2011 09:56
Show Gist options
  • Save itang/1080015 to your computer and use it in GitHub Desktop.
Save itang/1080015 to your computer and use it in GitHub Desktop.
scala> def a(x: Int) = {println("evaluated"); x * 100 }
a: (x: Int)Int
scala> val s : Stream[Int] = 1 #:: 2 #:: 3 #:: a(100) #:: Stream.empty
s: Stream[Int] = Stream(1, ?)
scala> s(0)
res0: Int = 1
scala> s.foreach(println)
1
2
3
evaluated
10000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment