title: Keep variable constant during recursion in Haskell
body: <p>I am trying to subtract the average of the list from each instance of the list. But the average changes with each recursion. How to make it so that the average stays static? Here's what I tried:</p>
  
  <pre><code>ave' :: (Fractional a, Real b) =&gt; [b] -&gt; a
  ave' xs = realToFrac (sum' xs) / (fromIntegral $ length xs)
  
  std_series :: (Floating a, Real a) =&gt; [a] -&gt; [a]
  std_series [] = []
  std_series (x:xs) = x - ave' (x:xs) : std_series xs
  </code></pre>