Skip to content

Instantly share code, notes, and snippets.

@letalvoj
Last active May 28, 2016 08:51
Show Gist options
  • Save letalvoj/9bb2d0e5632dc0a1b2b1bf2a1df36347 to your computer and use it in GitHub Desktop.
Save letalvoj/9bb2d0e5632dc0a1b2b1bf2a1df36347 to your computer and use it in GitHub Desktop.
Recursively defining scala streams by themselves
object RecursiveStreamComplexity extends App {
val integer = new AtomicInteger()
val foo: Stream[Int] = 1 #:: foo.map(i => {
integer.incrementAndGet()
i + 2
})
println(s"This ${foo.take(10).mkString(", ")} took ${integer.get()} operations")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment