Skip to content

Instantly share code, notes, and snippets.

@tanishiking
Last active December 24, 2015 09:16
Show Gist options
  • Save tanishiking/af6a0e9bce7b2a0ae408 to your computer and use it in GitHub Desktop.
Save tanishiking/af6a0e9bce7b2a0ae408 to your computer and use it in GitHub Desktop.
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