Last active
December 24, 2015 09:16
-
-
Save tanishiking/af6a0e9bce7b2a0ae408 to your computer and use it in GitHub Desktop.
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 MyStream { | |
def main(args: Array[String]): Unit = { | |
range(1, 10).take(10).print | |
} | |
private[this] def range(start: Int, end: Int): Stream[Int] = { | |
if(start >= end) { | |
Stream.empty | |
} else { | |
Stream.cons(start, range(start + 1, end)) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment