Anonymous user
Words containing "the" substring: Difference between revisions
m
→{{header|REXX}}: added the capability of suppressing the found words, and only display the count of found words.
m (→{{header|REXX}}: unplurized a word.) |
m (→{{header|REXX}}: added the capability of suppressing the found words, and only display the count of found words.) |
||
Line 170:
It also allows the substring to be specified on the command line (CL) as well as the dictionary file identifier.
Programming note: If the minimum length is negative, it indicates to find the words (but not display them), and
<br>only the display the count of found words.
<lang rexx>/*REXX program finds words that contain the substring "the" (within an identified dict.)*/
parse arg $ minL iFID . /*obtain optional arguments from the CL*/
Line 175 ⟶ 179:
if minL=='' | minL=="," then minL= 12 /* " " " " " " */
if iFID=='' | iFID=="," then iFID='unixdict.txt' /* " " " " " " */
tell= minL>0; minL= abs(minL) /*use absolute value of minimum length.*/
@.= /*default value of any dictionary word.*/
do #=1 while lines(iFID)\==0 /*read each word in the file (word=X).*/
Line 186 ⟶ 191:
if pos($u, z)==0 then iterate /*Found the substring? No, " " */
finds= finds + 1 /*bump count of substring words found. */
if tell then say right(left(@.j, 20), 25) /*Show it?
end /*j*/
/*stick a fork in it, we're all done. */
say copies('─', 25) finds " words (with a min. length of" ,
minL') that
{{out|output|text= when using the default inputs:}}
<pre>
Line 227 ⟶ 232:
weatherstripping
───────────────────────── 32 words (with a min. length of 12) that contain the substring: the
</pre>
{{out|output|text= when using the input of: <tt> , -3 </tt>}}
<pre>
───────────────────────── 25105 words in the dictionary file: unixdict.txt
───────────────────────── 287 words (with a min. length of 3) that contains the substring: the
</pre>
|