Last active
May 28, 2016 08:51
-
-
Save letalvoj/9bb2d0e5632dc0a1b2b1bf2a1df36347 to your computer and use it in GitHub Desktop.
Recursively defining scala streams by themselves
This file contains hidden or 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 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