13.Write a program in PROLOG to implement palindrome (L) which checks whether a list L is a palindrome or not.
%Write a program in PROLOG to implement palindrome (L) which checks whether
a list L is a palindrome or not.
% below palindrome function is not predefined you can use any name as function
palind([]):- write('palindrome').
palind([_]):- write('palindrome').
palind(L) :-
append([H|T], [H], L),
palind(T);
write('Not a palindrome').
% Output
No comments:
Post a Comment