I'm working on my homework for Prolog (SWI) but can't figure out how to get this done:
I have the functor:
palindrome([]).
palindrome([_]).
palindrome([A|T]) :-
append(Middle,[A],T),
palindrome(Middle).
which tells if a given list is a palindrome.
For my homework I have to write a functor palindrome/2
without append/3
and with difference lists.
I know a difference list is a form of [Y|X]-X
, but I don't understand how to use this and how this can replace the append functor.
Can somebody please explain this to me?