Created
May 7, 2012 19:34
-
-
Save leedm777/2629874 to your computer and use it in GitHub Desktop.
fibonacci sequence, in scala
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
val fib: Stream[BigInt] = { | |
def nextFib(a: BigInt, b: BigInt): Stream[BigInt] = { | |
Stream.cons(a + b, nextFib(b, a + b)) | |
} | |
Stream.cons(0, Stream.cons(1, nextFib(0, 1))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment