The Haskell Fibonacci program is even shorter than the Python program above.

fibonacci = 0 : 1 : [ this + next | (this, next) <- zip fibonacci (tail fibonacci) ]

Note that the list fibonacci actually contains every fibonacci number, in order. Haskell's lazy evaluation means that it won't actually generate the list until you ask for one of its elements.


jrn points out that calculating fibonacci numbers this way is slow and uses a bunch of memory. If you want to calculate fibonacci numbers in Haskell FAST, this is how you do it:

golden_ratio = (1 + (sqrt 5))/2

fibonacci_at :: Integer -> Integer
fibonacci_at n = round (golden_ratio^n/(sqrt 5))

But that's just not as cool as having an infinitely long list, is it? :)