Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Eertree/REXX/eertree.rexx
Normal file
19
Task/Eertree/REXX/eertree.rexx
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/*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.*/
|
||||
L= length(x) /*the length (in chars) of input string*/
|
||||
@.= . /*@ 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. */
|
||||
if reverse(y)\==y | @.y\==. then iterate /*Partial string a palindrome? Skip it*/
|
||||
@.y= y /*indicate a sub─palindrome was found. */
|
||||
$= $' ' y /*append the sub─palindrome to the list*/
|
||||
end /*k*/ /* [↑] an extra blank is inserted. */
|
||||
end /*j*/
|
||||
|
||||
say '──────── The input string that is being used: ' space(x)
|
||||
say '──────── The number of sub─palindromes found: ' words($)
|
||||
say '──────── The list of sub─palindromes found: ' strip($)
|
||||
/*stick a fork in it, we're all done. */
|
||||
Loading…
Add table
Add a link
Reference in a new issue