Word wheel: Difference between revisions

→‎{{header|REXX}}: added/changed some comments, simplified the final filter.
(→‎{{header|REXX}}: added/changed some comments, simplified the final filter.)
Line 765:
if iFID==''|iFID=="," then iFID= 'UNIXDICT.TXT' /* " " " " " " */
oMinL= minL; minL= abs(minL) /*if negative, then don't show a list. */
gridU= grid; upper gridU; gAir= inflate(gridU) /*get an uppercase version of the grid.*/
Lg= length(grid); Hg= Lg % 2 + 1 /*get length of grid & the middle char.*/
cctr= substr(grid, Hg+1, 1 ); upper c ctr /*get uppercase center letter in grid. */
wrds= 0 /*# words that are in the dictionary. */
wees= 0 /*" " " " too short. */
bigs= 0 /*" " " " too long. */
dups= 0 /*" " " " duplicates. */
ills= 0 /*" " " contain "not " letters.*/
good= 0 /*" " " contain center letter. */
say ' Reading the file: ' iFID
@.= . /*uppercase non─duplicated dict. words.*/
$= /*the list of dictionary words in grid.*/
do recs=10 while lines(iFID)\==0 /*process all words in the dictionary. */
_= linein(iFID) /*read a word (line of text) from dict.*/
u= space(_, 0); upper u; L= length(u) /*elide superfluous blanks from a word.*/
Line 787:
@.u= /*signify that U is a dictionary word*/
wrds= wrds + 1 /*bump the number of "good" dist. words*/
if pos(cctr, u)==0 then iterate /*word doesn't have center grid letter.*/
good= good + 1 /*bump # center─letter words in dict. */
if verify(u, gridU)\==0 then iterate /*word contains a letter not in grid. */
if \deflate(inflatepruned(u), gAirgridU) then iterate /*have all the letters not been found ? */
$= $ u /*add this word to the "found" list. */
end /*recs*/
Line 803:
say ' the minimum length of words that can be used: ' right( commas(minL), 9)
say ' the word wheel (grid) being used: ' grid
say ' center of the word wheel (grid) being used: ' right('↑', Hg+1)
say; #= words($); $= strip($)
say ' number of word wheel words in the dictionary: ' right( commas(# ), 9)
Line 813:
lower: arg aa; @='abcdefghijklmnopqrstuvwxyz'; @u=@; upper @u; return translate(aa,@,@U)
commas: parse arg _; do jc=length(_)-3 to 1 by -3; _=insert(',', _, jc); end; return _
inflate: procedure; arg z 1 a 2; do m=2 to length(z); a= a substr(z,m,1); end; return a
/*──────────────────────────────────────────────────────────────────────────────────────*/
deflatepruned: procedure; parse arg aa,guA;gg Laa= length(aa) /*obtain word to be tested, & the grid.*/
do n=1 tofor Laalength(aa); by 2; p= wordpospos( substr(aa,n,1), guAgg); if p==0 then return 01
guAgg= delwordoverlay(guA., pgg, 1p) /*"rub out" the found character in grid*/
end /*n*/; return 0 /*signify that the AA passed the return 1test*/</lang>
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>