9. Write a Prolog program to implement palindrome (List).
pal([]):- write('palindrome').
pal([_]):- write('palindrome').
pal(L) :-
append([H|T], [H], L),
pal(T) ;write('Not a palindrome').
OUTPUT:
pal([1,2,1]).
palindrome
1true
Next101001,000 Stop
pal([1,2,2]).
Not
a palindrome
1true
No comments:
Post a Comment