ABC words: Difference between revisions

Content added Content deleted
m (→‎{{header|REXX}}: added wording to the REXX section header.)
m (→‎{{header|REXX}}: added comments, changed indentation, added a 2nd output section for the vowels in order.)
Line 427: Line 427:
do #=1 while lines(iFID)\==0 /*read each word in the file (word=X).*/
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= strip( linein( iFID) ) /*pick off a word from the input line. */
$.#= x /*save: original case. */
$.#= x; upper x; !.#= x /*save: original case. */
end /*#*/ /* [↑] semaphore name is uppercased. */
end /*#*/ /* [↑] semaphore name is uppercased. */
say copies('─', 30) # "words in the dictionary file: " iFID
say copies('─', 30) # "words in the dictionary file: " iFID
L = length(chrs) /*obtain the length of the ABC chars.*/
L = length(chrs)
chrsU= chrs; upper chrsU /*obtain an uppercase version of chrs.*/
ABCs= 0 /*count of the "ABC" words found. */
ABCs= 0 /*count of the "ABC" words found. */
do j=1 for #-1 /*process all the words that were found*/
do j=1 for #-1 /*process all the words that were found*/
if verify(chrs, $.j)>0 then iterate
if verify(chrsU, !.j)>0 then iterate /*All characters found? No, then skip.*/
p= 0 /*initialize the position location. */
p=0
do k=1 for L
do k=1 for L /*examine each letter of the ABC charts*/
_= pos( substr(chrs, k, 1), $.j)
_= pos( substr(chrsU, k, 1), !.j) /*find the position of the Kth letter.*/
if _<p then iterate j
if _<p then iterate j /*Less than the previous? Then skip it*/
p= _
p= _ /*save the position of the last letter.*/
end
end /*k*/
ABCs= ABCs + 1 /*bump the count of "ABC" words found. */
ABCs= ABCs + 1 /*bump the count of "ABC" words found. */
say right(left($.j, 20), 24) /*indent original word for readability.*/
say right(left($.j, 30), 40) /*indent original word for readability.*/
end /*j*/
end /*j*/
say copies('─', 30) ABCs ' "ABC" words found using the characters: ' chrs</lang>
say copies('─', 30) ABCs ' "ABC" words found using the characters: ' chrs</lang>
{{out|output|text=&nbsp; when using the default input:}}
'''output'''
<pre>
<pre>
────────────────────────────── 25105 words in the dictionary file: unixdict.txt
────────────────────────────── 25105 words in the dictionary file: unixdict.txt
aback
aback
abacus
abacus
abc
abc
abdicate
abdicate
abduct
abduct
abeyance
abeyance
abject
abject
abreact
abreact
abscess
abscess
abscissa
abscissa
abscissae
abscissae
absence
absence
abstract
abstract
abstracter
abstracter
abstractor
abstractor
adiabatic
adiabatic
aerobacter
aerobacter
aerobic
aerobic
albacore
albacore
alberich
alberich
albrecht
albrecht
algebraic
algebraic
alphabetic
alphabetic
ambiance
ambiance
ambuscade
ambuscade
aminobenzoic
aminobenzoic
anaerobic
anaerobic
arabic
arabic
athabascan
athabascan
auerbach
auerbach
diabetic
diabetic
diabolic
diabolic
drawback
drawback
fabric
fabric
fabricate
fabricate
flashback
flashback
halfback
halfback
iambic
iambic
lampblack
lampblack
leatherback
leatherback
metabolic
metabolic
nabisco
nabisco
paperback
paperback
parabolic
parabolic
playback
playback
prefabricate
prefabricate
quarterback
quarterback
razorback
razorback
roadblock
roadblock
sabbatical
sabbatical
snapback
snapback
strabismic
strabismic
syllabic
syllabic
tabernacle
tabernacle
tablecloth
tablecloth
────────────────────────────── 55 "ABC" words found using the characters: abc
────────────────────────────── 55 "ABC" words found using the characters: abc
</pre>

{{out|output|text=&nbsp; when using the &nbsp;(vowels in order)&nbsp; input: &nbsp; &nbsp; <tt> aeiou </tt>}}
<pre>
────────────────────────────── 25105 words in the dictionary file: unixdict.txt
adventitious
facetious
────────────────────────────── 2 "ABC" words found using the characters: aeiou
</pre>
</pre>