Changeable words: Difference between revisions
Content deleted Content added
m →{{header|REXX}}: changed whitespace and some comments, used a better variable name, optimized the inner DO loop. |
|||
Line 567:
Labc= length(abc) /*the length of the alphabet to be used*/
do j=1 for #-1; L= length($.j)
if L<minL then iterate /*Is the word long enough? No, skip it*/
if \datatype($.j, 'M') then iterate /*verify that the word is all letters. */
x= $.j; upper x /*get an uppercased version of the word*/
do k=1 for L;
do c=1 for Labc /* [↓] change the _ letter to another.*/
?= substr(abc, c, 1) /*get a new char to replace one in word*/
if ?==
new= overlay(?, x, k) /*create a spanking new (changed) word.*/
newU= new; upper newU /*get an uppercase version of new word.*/
if @.newU=='' then iterate /*if the new word isn't a word, skip it*/
end /*c*/
end /*k*/
end /*j*/▼
▲ finds= finds + 1 /*bump count of changeable words found.*/
▲ say right( left($.j, 30), 40) @.newU /*indent original word for readability.*/
▲ end /*j*/
say copies('─', 30) finds ' changeable words found with a minimum length of ' minL</lang>
{{out|output|text= when using the default inputs:}}
|