title: Count instances of each unique integer in a vector in 1 line of code?
body: <p>Is there a slick way to rewrite this Julia function, perhaps using just 1 line of code, without making it much slower? (I just started using Julia. It's great!) <code>K</code> is a positive integer and <code>zd</code> is a vector of positive integers no greater than <code>K</code>. Thanks!</p>
  
  <pre><code>function tally(zd)
      ret = zeros(Int64, K)
      for k in zd
          ret[k] += 1
      end
      return ret 
  end
  </code></pre>
  
  <p>Example:</p>
  
  <pre><code>julia&gt; K = 5
  julia&gt; zd = [1,2,2,2,2,3];
  julia&gt; tally(zd)
  5-element Array{Float64,1}:
   1
   4
   1
   0
   0
  </code></pre>