Subject: Re: palindrome problem

From: "Richard A. O'Keefe" <[email-masked]>
Date: Mon, 15 May 2000 14:13:31 +1200 (NZST)

I want to define the predicate palindrome(Base,Result), assuming
	that Result is always even length list. For example,
	
	palindrome([m,a,d],R). 
	R = [m.a.d.d.a.m] ;
	
	palindrome(B,[n,i,s,s,i,n]). 
	B = [n,i,s] ;
	
I am going to indulge in one of my favouriate resonses:
I'm going to provide a correct answer such that someone who
can explain it could have solved the problem anyway.

    palindrome(B, R) :-
	palindrome(B, R, []).

    palindrome([], R, R).
    palindrome([X|B], [X|R], T) :-
	palindrome(B, R, [X|T]).