palindrome.pl

loading
details
attribute value
description
owner Johannes Waldmann
uploaded 2017-08-17 03:45:07.0
disk size 441 Bytes
downloadable true
type
attribute value
name no_type
processor id 1
description this is the default benchmark type for rejected benchmarks and benchmarks that are not associated with a type.
owning community none
loading contents
%query: palindrome(i).

/* Folklore. */

palindrome(L):- halves(L,X1s,X2s,EvenOdd), eq(EvenOdd,even), eq(X1s,X2s).
palindrome(L):- halves(L,X1s,X2s,EvenOdd), eq(EvenOdd,odd), last(X1s,_,X2s). 
                
halves([],[],[],even).
halves([X],[X],[],odd).
halves([T,Y|Xs],[T|Ts],[R|Rs],EvenOdd):-
        last([Y|Xs],R,Rests),
        halves(Rests,Ts,Rs,EvenOdd).    


last([T],T,[]).
last([H|T],X,[H|M]) :-
        last(T,X,M).

eq(X,X).
popout

content may be truncated. 'popout' for larger text window.

actions get anonymous link download benchmark