Please help me with how to count even numbers in a list in Prolog. I am a beginner, just started learning Prolog yesterday. I know to count the elements in the list is
mylen([H|Lc],N) :- mylen(Lc,M),N is M+1.
mylen([],0).
And I think defining even number maybe helpful in this case, and I guess the code is maybe something like:
even(n):-
N rem 2 =:= 0.
Can you help me with putting these two parts together, so my code counts even numbers? I know I also need to add a counter, but I have no idea of how to do this in Prolog.
Thank you so very much for you help!