Anonymous user
Palindrome detection: Difference between revisions
→{{header|Prolog}}: added non-recursive, tested and working...
m (→Non-recursive: Typo) |
(→{{header|Prolog}}: added non-recursive, tested and working...) |
||
Line 336:
</lang>
=={{header|Prolog}}==
===Non-recursive===
From [http://www2.dcs.hull.ac.uk/NEAT/dnd/AI/prolog/tutorial2.html this tutorial].
<lang prolog>palindrome(Word) :- name(Word,List), reverse(List,List).</lang>
===Recursive===
<lang prolog>pali(str) :- conlist([x, mid, x], str), str_len(x, 1), pali(mid).
|