public
Created

Fibonacci

  • Download Gist
Fibs.hs
Haskell
1 2 3 4 5 6 7 8 9 10 11 12 13
{-# LANGUAGE BangPatterns #-}
 
module Main where
 
zipWith' :: (t -> t1 -> a) -> [t] -> [t1] -> [a]
zipWith' f (!x:xs) (!y:ys) = f x y : zipWith' f xs ys
zipWith' _ _ _ = []
 
fibs :: [Integer]
fibs = 0 : 1 : zipWith' (+) fibs (tail fibs)
 
main :: IO ()
main = print . head . drop (10^6) $ fibs

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.