title: How does Haskell process a list?
body: <p>A few of us at work have been reading some on Haskell and we were talking about some of the concepts yesterday.  The question came up with Haskell being a lazy language, how does it handle retrieving the nth element of a list?</p>
  
  <p>For example, if we had</p>
  
  <pre><code> [2,4..10000000] !! 200
  </code></pre>
  
  <p>Would it actually populate the list up to 200 elements?  Or does it compile it down into an equation similar to</p>
  
  <pre><code>n*step + firstValue
  </code></pre>
  
  <p>and then return that calculation?  The reason this came up was someone was trying to come up with an example where a program would easily run out of memory, and the thought of traversing down a (sufficiently large) list was the first candidate that came up.</p>