Write a program in PROLOG to implement palindrome (L) which checks whether a list L is a palindrome or not.

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

Featured post

Amazon Interview Process

On July 5, 1994, Jeff Bezos started the world's most "customer-centric" firm out of his garage in Bellevue, Washington. The A...