title: counting the number of a particular element in a prolog list
body: <p>I am trying to count how many times a element appears in a list, so far I have came up with</p>
  
  <pre><code>rate(X,[H|T],N):-
    X == H,
    N is N+1,
    rate(X,T,N).
  rate(X,[_|T],N) :-
    rate(X,T,N).  
  rate(_,[],N) :-
    N is 0.
  </code></pre>
  
  <p>I've covered when the a match is found, when there isn't a match and when it reaches the end of the list. But when i test i get</p>
  
  <pre><code>43 ?- rate(4,[4,2,3,4,4,2],X).
  ERROR: is/2: Arguments are not sufficiently instantiated
  Exception: (6) frequency(4, [4, 2, 3, 4, 4, 2], _G393) ?     
  </code></pre>
  
  <p>What arguments am i missing exactly?</p>