Fibonacci numbers in Scala

Example for versions Scala 2.7.7-final, Simply Scala

This example shows the usage of lazy evaluations and infinite lists in Scala. Infinite list of Fibonacci numbers is defined using functions .zip and .tail in the same way as in Haskell example.

lazy val fib: Stream[Int] = Stream.cons(1, Stream.cons(1, => p._1 + p._2)))