You are viewing a single comment's thread. Return to all comments →
Indeed, an infinite list is much more elegant in Haskell.
import Control.Monad ( replicateM_ ) dial :: [Int] -> IO () dial fibs = readLn >>= (pure . (fibs !!)) >>= print main = do -- Fibonacci list let fibs = let f x y = (x + y) `rem` 100000007 in 0 : 1 : (zipWith f fibs (drop 1 fibs)) readLn >>= flip replicateM_ (dial fibs)
Fibonacci
You are viewing a single comment's thread. Return to all comments →
Indeed, an infinite list is much more elegant in Haskell.