Eertree: Difference between revisions
Content deleted Content added
Go solution |
m →{{header|REXX}}: elided superfluous blank lines. |
||
Line 436:
This REXX program is modeled after the '''Ring''' example.
<lang rexx>/*REXX program creates a list of (unique) sub─palindromes that exist in an input string.*/
parse arg x . /*obtain optional input string from CL.*/
if x=='' | x=="," then x= 'eertree' /*Not specified? Then use the default.*/
Line 442 ⟶ 441:
@.=. /*@ tree indicates uniqueness of pals. */
$= /*list of unsorted & unique palindromes*/
do j=1 for L /*start at the left side of the string.*/
do k=1 for L /*traverse from left to right of string*/
parse var x =(j) y +(k) /*extract a substring from the string. */
Line 452 ⟶ 449:
$=$' ' y /*append the sub─palindrome to the list*/
end /*k*/ /* [↑] an extra blank is inserted. */
end /*j*/
Line 460 ⟶ 456:
#=words($) /*get the number of palindromes found. */
subP= 'sub─palindromes' /*a literal to make SAY texts shorter. */
say pad 'The number of' subP "found: " #
say
say pad 'The list of' subP "found: " /*display the list of the palindromes. */
say strip($) /*
{{out|output|text= when using the default input:}}
<pre>
|