How would I write a prolog program like the one below that succeeds if the list has the same first and last element but without recursion using the append predicate only?
firstlast([H,H]).
firstlast([F,_|T]) :- firstlast([F|T]).
Sample queries:
?- firstlast([1,2,3,1]).
Yes
?- firstlast([1,2,3]).
No
Lastof a list withappend(_, [Last], L). - Willem Van Onsem