Palindrome detection: Difference between revisions

→‎{{header|ed}}: Minor grammatical fix
(→‎{{header|Uiua}}: Added an extra credit solution)
(→‎{{header|ed}}: Minor grammatical fix)
(One intermediate revision by the same user not shown)
Line 1,911:
;;(equal? (string->list string) (reverse (string->list string)))))
</syntaxhighlight>
 
=={{header|ed}}==
 
A limitation: due to ed having no built-in loops, the part with palindrome beginning/end matching has to be repeated as many times as there are palindrome levels. As a sane default, 15 is used here.
 
<syntaxhighlight lang="sed">
# by Artyom Bologov
H
,p
g/^(.)(.+)\1$/s//\2/
g/^(.)(.+)\1$/s//\2/
g/^(.)(.+)\1$/s//\2/
g/^(.)(.+)\1$/s//\2/
g/^(.)(.+)\1$/s//\2/
g/^(.)(.+)\1$/s//\2/
g/^(.)(.+)\1$/s//\2/
g/^(.)(.+)\1$/s//\2/
g/^(.)(.+)\1$/s//\2/
g/^(.)(.+)\1$/s//\2/
g/^(.)(.+)\1$/s//\2/
g/^(.)(.+)\1$/s//\2/
g/^(.)(.+)\1$/s//\2/
g/^(.)(.+)\1$/s//\2/
g/^(.)(.+)\1$/s//\2/
v/^(.)(.+)\1$|^.$/s/.*/Not a palindrome!/
g/^.$/s//Palindrome!/
,p
Q
</syntaxhighlight>
 
{{out}}
 
<pre>$ cat palindrome.ed | ed -lEGs palindrome.input
rotor
racecar
level
rosetta
Palindrome!
Palindrome!
Palindrome!
Not a palindrome!</pre>
 
=={{header|Eiffel}}==
100

edits