Letter frequency: Difference between revisions

Content deleted Content added
m →‎{{header|REXX}}: made REXX example compliant. -- ~~~~
Line 1,136: Line 1,136:


=={{header|REXX}}==
=={{header|REXX}}==
<lang rexx>/* counts the occurances of all characters in a file, */
<lang rexx>/*REXX program counts the occurances of all characters in a file, */
/* {all Latin alphabet letters are uppercased first}. */
/* {all Latin alphabet letters are uppercased first}. */
@.=0

parse arg fileID .
parse arg fileID .
if fileID=='' then fileID='JUNK.TXT'
if fileID=='' then fileID='JUNK.TXT'
@.=0


do j=1 while lines(fileID)\==0 /*read file until cows come home.*/
do j=1 while lines(fileID)\==0 /*read file until cows come home.*/
_=linein(fileID) /*get a line from the file. */
$=linein(fileID) /*get a line from the file. */
upper _ /* ◄──────────────────────uppercase the Latin characters.*/
upper $ /* ◄──────────────────────uppercase the Latin characters.*/
do k=1 for length($) /*examine/count each character. */

do k=1 for length(_) /*examine/count each character. */
x=c2x(substr($,k,1)) /*convert the character to hex. */
x=c2x(substr(_,k,1)) /*convert the character to hex. */
@.x=@.x+1 /*bump the character's count. */
@.x=@.x+1 /*bump the character's count. */
end /*k*/
end /*k*/

end /*j*/
end /*j*/