I am trying to create a predicate in prolog called isDuped( Y ) that only succeeds if Y is a list of even length and each element in the list appears twice in a row (i.e. [1,1,2,2,3,3,4,4]).
What I currently have is:
isDuped( Y ) :-
Y == [].
isDuped( Y ) :-
[ A, B | C ] = Y,
A == B,
isDuped( C ).
However, one of my professor's unit tests is supposed to return true, but as I have it written it returns false. isDuped([1,_]) is supposed to return true, but I have no idea what I need to change. Any help would be appreciated.