So I need to write a prolog term called doubleAll7/2 that takes two lists. The program returns true if for every 7 that occurs in the first list, the second list has two sevens in a row.
Example doubleAll7([1,7,1],[1,7,7,1]) is true but doubleAll7([1,2,7],[1,2,7]) is false.
double7/2 doubles all occurrences of 7 in a list and works perfectly.
For some reason this program always returns false.
doubleAll7([H1|T1],[H2,T2]) :-
double7([H1|T1], L),
L == [H2|T2].
double7([],[]).
double7([H|T], [H,H|Z]) :-
H is 7,
!,
double7(T,Z).
double7([H|T], [H|Z]) :-
double7(T,Z).