Jump to content

ABC words: Difference between revisions

m
→‎{{header|REXX}}: changed a comment, changed wording in the REXX section header.
m (added whitespace.)
m (→‎{{header|REXX}}: changed a comment, changed wording in the REXX section header.)
Line 421:
=={{header|REXX}}==
This REXX version doesn't care what order the words in the dictionary are in,   nor does it care what
<br>case &nbsp;(lower/upper/mixed)&nbsp; the words are in, &nbsp; the search for the "&nbsp; ''ABC"'' &nbsp; words is &nbsp; ''caseless''.
 
It also allows the &nbsp; (ABC) &nbsp; characters to be specified on the command line (CL) as well as the dictionary file identifier.
<lang rexx>/*REXX pgm finds "ABC" words (within an identified dict.) where ABC are found in order.*/
parse arg chrs iFID . /*obtain optional arguments from the CL*/
if chrs=='' | chrs=="," then chrs= 'abc' /*Not "specified? Then use the " " " " " default.*/
if iFID=='' | iFID=="," then iFID='unixdict.txt' /* " " " " " " */
@.= /*default value of any dictionary word.*/
do #=1 while lines(iFID)\==0 /*read each word in the file (word=X).*/
x= strip( linein( iFID) ) /*pick off a word from the input line. */
$.#= x; upper x; !@.#= x /*save: original case. */
end /*#*/ /* [↑] semaphore name is uppercased. */
say copies('─', 30) # "words in the dictionary file: " iFID
Line 438:
ABCs= 0 /*count of the "ABC" words found. */
do j=1 for #-1 /*process all the words that were found*/
if verify(chrsU, !@.j)>0 then iterate /*All characters found? No, then skip.*/
p= 0 /*initialize the position location. */
do k=1 for L /*examine each letter of the ABC charts*/
_= pos( substr(chrsU, k, 1), !@.j) /*find the position of the Kth letter.*/
if _<p then iterate j /*Less than the previous? Then skip it*/
p= _ /*save the position of the last letter.*/
Cookies help us deliver our services. By using our services, you agree to our use of cookies.