Semordnilap: Difference between revisions
Content deleted Content added
m added whitespace, added section headers. |
m →version 2: added/changed comments and whitespace, changed indentations. |
||
Line 1,996:
This REXX version makes use of sparse (stemmed) arrays.
<br><br>The dictionary file wasn't assumed to be in any particular case (upper/lower/mixed).
<br>For instance, '''DNA''' <big> & </big> '''and''' would be considered palindromes.
<br>The UNIXDICT dictionary specified to be used ''is'' all lowercase, however, but the REXX
<br>program assumes that the words may be in any ''case'' (upper, lower, mixed).
Line 2,004:
<br>The palindrome pairs are shown with a comma delimiter in case there're phrases (words with imbedded blanks like Sing Sing).
<br>The (first five) palindrome pairs are shown as they are specified (respective to case) in the dictionary.
<lang rexx>/*REXX program finds palindrome pairs
#=0 /*
parse arg iFID .; if iFID=='' then iFID='UNIXDICT.TXT' /*
@.= /*
do while lines(iFID)\==0; _=space(linein(iFID),0)
if @.r\=='' then do; #=#+1
end /*while*/ /* [↑] read the dictionary. */
say
say "There're " # ' unique palindrome pairs in the dictionary file: ' iFID
/*stick a fork in it, we're done. */</lang>
'''output''' when using the default dictionary as the input:
<pre>
ac, ca
|