[Haskell] Fibonacci sequence and memoization

3    23 Sep 2015 19:54 by u/the_spectre

Hey, I'm working on learning Haskell and am trying to figure out memoization, but it's warping my mind. I don't really conceptually understand how it works. If you have the free time, would you mind explaining how I'd go about memoizing this simple program?

import System.Environment
fibo :: [Integer]
fibo = 0 : 1 : zipWith (+) fibo (tail fibo)
main = do
        args <- getArgs
        let arg = read (head args) :: Int
        print $ fibo !! arg

0 comments

No comments archived.