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}. */ |
||
⚫ | |||
parse arg fileID . |
parse arg fileID . |
||
if fileID=='' then fileID='JUNK.TXT' |
if fileID=='' then fileID='JUNK.TXT' |
||
⚫ | |||
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. */ |
|||
upper |
upper $ /* ◄──────────────────────uppercase the Latin characters.*/ |
||
⚫ | |||
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*/ |
||