It seems that everyone is voting for a solution based on the opposite / 2. I think you guys have the inverse / 2 solution, i.e. O (n) of this list. Something with a battery:
reverse(X,Y) :- reverse(X,[],Y). reverse([],X,X). reverse([X|Y],Z,T) :- reverse(Y,[X|Z],T).
But there are other ways to test a palindrome. I came up with a solution that uses DCG. You can use the following rules:
palin --> []. palin --> [_]. palin --> [Border], palin, [Border].
Which solution is better? Well, let's get some statistics through the Prolog system team profile. Here are the results:

So, perhaps the DCG solution is often faster in the positive case ("radar"), it does not have to collect the entire reverse list, but moves directly to the middle, and then checks the rest, leaving its own recursion. But the disadvantage of the DCG solution is that it is not deterministic. Some measurements of time will tell more ...
Bye
PS: port statistics with the new Jekejeke Prolog pluggable debugger:
http://www.jekejeke.ch/idatab/doclet/prod/en/docs/10_dev/10_docu/02_reference/04_examples/02_count.html
But other Prolog systems have similar capabilities. For more information, see the Code Profiler column:
http://en.wikipedia.org/wiki/Comparison_of_Prolog_implementations
source share