title: How to consider previous elements when mapping over a list?
body: <p>I'm stuck at making a function in Haskell wich has to do the following:</p>
  
  <p>For each integer in a list check how many integers in front of it are smaller.</p>
  
  <pre><code>smallerOnes [1,2,3,5] will have the result [(1,0), (2,1), (3,2), (5,3)]
  </code></pre>
  
  <p>At the moment I have: </p>
  
  <pre><code>smallerOnes :: [Int] -&gt; [(Int,Int)]
  smallerOnes [] = []
  smallerOnes (x:xs) =  
  </code></pre>
  
  <p>I don't have any clue on how to tackle this problem. Recursion is probably the way of thinking here but at that point I'm losing it.</p>