I am battling with prolog like a weary adversary, and i'd like some help or even just to tell me where i'm going wrong. I've got a list of 6 items which i then turn into 3 pairs of colours. I then try and run a check on it to see if it identifies the pair of colours within the list. When i run it, it converts the pairs, does the check, but only finds the pair when they are the first item in the list. I am thinking my tail recursion is wrong. If anyone could help, greatly appreciated. Thanks. (Code below)
makepairs([],[]).
makepairs([X1,X2|T],[[X1,X2]|B]):-makepairs(T,
isredwhite([], 0).
isredwhite([X1|_], XP):-member(red,X1),member(white,X1), XP is 1.
isredwhite([_|T], 0):-isredwhite(T, 0).
:- dynamic cube/6.
initialize:-
makepairs([red,whitea,red,white,red,green],Xnew),
assert(cube(1,Xnew,0,0,0,0)),write(Xnew),nl,
isredwhite(Xnew, Xhasredwhiter),write(Xhasredwhiter),nl,
cube(2,Xnew,0,0,0,0)=L,
write(L),nl.
sortcubes:- initialize.
Thanks again.











