<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    When I previously asked about memoization, I got the impression that
    memoization is not something that just happens magically in Haskell.
    Yet, on a Haskell wiki page about <a
href="http://www.haskell.org/haskellwiki/Memoization#Memoization_with_recursion">Memoization</a>,
    an example given is<br>
    <br>
    <blockquote>
      <pre>memoized_fib :: Int -&gt; Integer
memoized_fib = (map fib [0 ..] !!)
&nbsp;&nbsp; where fib 0 = 0
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fib 1 = 1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fib n = memoized_fib (n-2) + memoized_fib (n-1)</pre>
    </blockquote>
    <br>
    I guess this works because, for example, I tried "memoized_fib
    10000" and the interpreter took three or four seconds to calculate.
    But every subsequent call to "memoized_fib 10000" returns
    instantaneously (as does "memoized_fib 10001").<br>
    <br>
    Could someone explain the technical details of why this works? Why
    is "map fib [0 ..]" not recalculated every time I call memoized_fib?<br>
  </body>
</html>