title: Histogram in Haskell
body: <p>I have the following problem:</p>
  
  <blockquote>
    <p>Define a function <code>histogram :: Int -&gt; [Int] -&gt; [Int]</code> such that
    <code>histogram n xs</code> returns a list that counts the frequency of
    values drawn from <code>xs</code> in the ranges <code>0..n-1, n..2n-1, 2n..3n-1, ...</code> and
    so on, until all values in <code>xs</code> have been counted. For example,
    <code>histogram 5 [1, 2, 10, 4, 7, 12]</code> <strong>=></strong> <code>[3, 1, 2]</code>.</p>
  </blockquote>
  
  <p>I have tried various approaches to this problem including first defining a function <code>range</code> which produces list of tuples like: <code>range 3</code> <strong>=></strong> <code>[(0,2),(3,5),...]</code> to infinity, but I cannot seem to find appropriate solution to the whole problem. Any ideas would be really appreciated.</p>