title: Get value from last function call
body: <p>I want to write this method in Haskell:</p>
  
  <pre><code>private static int maxSubSumme(int array[])
  {
      int maximum  = 0;
      int maxright = 0;
  
      for(int i=array.length-1; i &gt; -1; i--)
      {
          maxright = Math.max(maxright + array[i], 0);
          maximum = Math.max(maximum, maxright);
      }
  
      return maximum; 
  }
  </code></pre>
  
  <p>I tried with this code:</p>
  
  <pre><code>maxSubSumme :: [Int] -&gt; Int
  maxSubSumme [x] = x
  maxSubSumme (x:l) | maxright &lt; maximum = maximum 
                    | maxright &gt; maximum = maxright
                    where 
                        maxright = maxi (x + (maxSubSumme l)) 0
                        maximum  = maxi maximum maxright -- Here is my problem
  
  maxi :: Int -&gt; Int -&gt; Int
  maxi x y | x &gt; y     = x
           | otherwise = y
  </code></pre>
  
  <p>I have to get the old maximum but I have no idea how I can do this. Is it possible to get the maximum from the last function call?</p>