Fibonacci numbers in Haskell
Example for versions
GHC 6.10.4
This is another example which uses lazy evaluation and a different, shorter form of producing output in required format.
main = putStrLn $ withDots $ join $ take 16 fibs
where fibs = 1 : 1 : zipWith (+) fibs (tail fibs)
join = foldl (\a b -> a ++ show b ++ ", " ) ""
withDots = (++ "...")
Comments
]]>blog comments powered by Disqus
]]>