count([ ],_ ,0). count([X|Xs],X0,N) :- ( X0 = X -> count(Xs,X0,N1), N is N1 + 1 ; count(Xs,X0,N) ).