findThree([H|T],_,3).
findThree([H|T], M, Z):-
( member(H,M)
-> Z2 is Z + 1,
select(H,M,C),
findThree(T,C,Z2)
;select(H,M,C),
findThree(T,C,Z)
).
So, what I'm trying to do is see if an element is in a specified list. If it is, I increment some variable, and stop if I found 3 of those elements. However, this does not seem to be working for me- is it a problem with my syntax? I'm trying to use an If-else construct in SWI-Prolog; could that be the issue?