title: How do I count the number of elements in a list?
body: <p>I need to write a small Prolog program to count the number of occurrence of each element in a list.</p>
  
  <pre><code>numberOfRepetition(input, result)
  </code></pre>
  
  <p>For example:</p>
  
  <pre><code>numberOfRepetition([a,b,a,d,c,a,b], X)
  </code></pre>
  
  <p>can be satisfied with <code>X=[a/3,b/2,d/1,c/1]</code> because <code>a</code> occurs three times, <code>b</code> occurs 2 times and <code>c</code> and <code>d</code> one time.</p>