I am trying to count how many times a element appears in a list, so far I have came up with
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.
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
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) ?
What arguments am i missing exactly?