title: How do accumulators work in Haskell?
body: <p>Hello i am trying to understand how do accumulators work by creating the following method :</p>
  
  <p>It receives a number and it creates a tuple of: <code>(sum [0..nr], [0..nr])</code>. For instance, given <code>4</code>, it should return <code>(10, [0,1,2,3,4])</code>.</p>
  
  <p>This is the code I have:</p>
  
  <pre><code>accu :: Int -&gt; (Int, [Int])
  accu 0  = (0, [0])
  accu nr = go (0, []) nr where   --I do not get this line, mainly the first argument
              go (s,ls) 0  = (s, 0:ls)
              go (s,ls) nr = go (s+nr, nr:ls) (nr-1)
  </code></pre>
  
  <p>I do not understand how the accumulator changes its value, since it is not a function, and thus shouldn't it be immutable? Shouldn't it be like a constant in my case?</p>