Longest palindromic substrings: Difference between revisions
Content deleted Content added
m added related tasks. |
m →{{header|REXX}}: shortened a long statement (line), add/changed comments and whitespace. |
||
Line 733:
<lang rexx>/*REXX program finds and displays the longest palindromic string(s) in a given string. */
parse arg s /*obtain optional argument from the CL.*/
if s==''
/* [↑] the case of strings is respected*/
do LL=2 for L-1 /*start with palindromes of length two.*/
if
end
call find 0 /*find all palindromes with length LL.*/
▲ LL= max(1,m)
▲ say ' longest palindromic substrings for string: ' x
do n=1 for words(@) /*show longest palindromic substrings. */
▲ say '────────────────────────────────────────────'copies('─', 2 + L)
say '
end /*n*/; say;
end
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
find: parse arg short /*if SHORT==1, only find 1 palindrome.*/
@= /*initialize palindrome list to a null.*/
@= @ $
if short then
end /*j*/; return 0
{{out|output|text= when using the default input:}}
<pre>
|