title: How can I count the number of times an element is greater than its successor?
body: <p>I'm currently trying to solve the following exercise:</p>
  <p>Given a list of <code>Int</code>s, count the number of times, an element is greater than the element that comes after it. The exercise forces me not to use explicit recursions.</p>
  <p>Here are some example outputs given <code>function :: [Int] -&gt; Int</code>:</p>
  <pre><code>function [1, 2, 3, 4, 5]         == 0  -- only increasing numbers
  function [5, 4, 3, 2, 1]         == 4  -- only decreasing numbers
  
  function [2,  1,  3,  1,  0,  4] == 3
  --        2 &gt; 1  
  --                3 &gt; 1
  --                    1 &gt; 0
  
  function [1] == 0 -- no successor
  function [ ] == 0 -- no numbers at all
  </code></pre>
  <p>I imagined to use in some way <code>foldl</code> but after many attempts and not working idea I had to give up.</p>
  <p>How can I count the number of times an element is greater than its successor without using recursion?</p>