Wednesday, February 21, 2024

Find out whether a list is a palindrome.

 

Find out whether a list is a palindrome.

my_reverse(L1,L2) :- my_rev(L1,L2,[]).


my_rev([],L2,L2) :- !.

my_rev([X|Xs],L2,Acc) :- my_rev(Xs,L2,[X|Acc]).

is_palindrome(L) :- reverse(L,L).

No comments:

Post a Comment