Teacup rim text: Difference between revisions

Content deleted Content added
PureFox (talk | contribs)
m →‎{{header|Wren}}: Minor tidy
Walterpachl (talk | contribs)
→‎{{header|REXX}}: make it ooRexx compliant and READABLE
 
Line 1,750:
 
=={{header|REXX}}==
All words that contained non─letternon-letter (Latin) characters   (periods, decimal digits, minus signs,
underbars, or embedded blanks)  
<br>weren't considered as candidates for circular words.
 
Line 1,759:
 
The dictionary wasn't assumed to be sorted in any way.
<syntaxhighlight lang="rexx">/*REXX pgm finds circular words (length>2), using a dictionary, suppress permutations.*/
/*REXX pgm finds circular words (length>2), using a dictionary, suppress permutations.*/
parse arg iFID L . /*obtain optional arguments from the CL */
if iFID==''|iFID=="," then iFID= 'wordlist.10k' /*Not specified? Then use the default.*/
if LiFID==''| LiFID=="," then LiFID= 3 'unixdict.txt' /*Not "specified? Then use the " " " " " default*/
#if L==''| 0 L=="," then L=3 /* " " " " " /*number of words in dictionary," Len>L.*/
word.=0
@.= /*stemmed array of non─duplicated words*/
have.=0
do r=0 while lines(iFID) \== 0 /*read all lines (words) in dictionary.*/
do r=0 while lines(iFID)>0 parse upper value linein(iFID) with z . /*obtainread aall wordlines from(words) thein dictionary. */
parse upper value linein(iFID) with w . /*obtain a word from the dictionary. */
if length(z)<L | @.z\=='' then iterate /*length must be L or more, no dups.*/
if length(w)>=3 &, if \datatype(z, 'U') then iterate /*Wordlength must be L or more contains non-letters? Then skip*/
datatype(w,'U') &, @.z = z /*Word must be all letters /*assign a word from the dictionary. */
have.w=0 then #=do # + 1; $.#= z /*No duplicates /*bump word count; append word to list.*/
z=word.0+1 end /*r*/ /* number of eligible words /* [↑] dictionary need not be sorted. */
word.0=z
cw= 0 /*the number of circular words (so far)*/
word.z=w /*Word number z */
say "There're " r ' entries in the dictionary (of all types): ' iFID
have.w=1 /*is available */
say "There're " # ' words in the dictionary of at least length ' L
end /*r*/ /*dictionary need not be sorted. */
End
@.cw= 0 /*stemmedthe arraynumber of non─duplicatedcircular words (so far)*/
say "'There''re " ' r ' entries in the dictionary (of all types): in the dictionary' iFID
say "'There''re " # ' word.0 ' words in the dictionary of at least length ' L
say
do j=1 To word.0 do j=1 for #; x= $.j; y= x /*obtain theloop through words Jth word in the list. */
if x==word.j>'' then iteratedo /*if aword is available null, don't show variants. */
w=word.j yy= y /* base for circulation /*the start of a list of the variants. */
lw=length(w) do k=1 for length(x)-1 /*"circulate" thenumber of letters litters in the word. */
cl=w
y= substr(y, 2)left(y, 1) /*add the left letter to the right end.*/
ci=1
if @.y=='' then iterate j /*if not a word, then skip this word. */
do k=1 for lw-1 yy= yy',' y /*append to'circulate' the listletters ofin the variantsword. */
@.yw=substr(w,2)left(w,1) /*move the first letter to the end. /*nullify word to suppress permutations*/
If have.w Then Do end /*k*/available word */
cw cl=cl','w cw + 1 /*add it to list /*bump counter of circular words found.*/
say 'circularci=ci+1 word: ' yy /*displaylist items a circular word and variants.*/
have.w=0 /*no longer available */
end /*j*/
End
Else
Leave
end /*jk*/
If ci=lw Then Do /*complete list */
say 'circular word: ' cl /*display a circular word and variants.*/
cw= 0 cw=cw + 1 /*thebump numbercounter of circular words (so far)found.*/
End
End
end /*j*/
say
say cw ' circular words were found.' /*stick a fork in it, we're all done. */</syntaxhighlight>
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>
There're 1000025104 entries in the dictionary (of all types): in the dictionary wordlistunixdict.10ktxt
There're 957824819 words in the dictionary of at least length 3
 
circular word: AIMAPT, IMAPTA, MAITAP
circular word: ARC, RCA, CAR
circular word: ASPATE, SPATEA, PASEAT
circular word: ATE, TEA, EAT
circular word: IPS, PSI, SIP
 
53 circular words were found.
</pre>