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