Palindrome detection: Difference between revisions

Add ed example
(→‎{{header|Uiua}}: Added an extra credit solution)
(Add ed example)
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 and there's 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}}==
104

edits