Letter frequency: Difference between revisions

m (→‎{{header|Phix}}: output ten per line)
Line 1,372:
 
=={{header|AutoHotkey}}==
<br>This is the past version of this edit but made into a function, and now it only shows the letters that are in it, but not the ones with 0 letters
<lang AutoHotkey>OpenFile = %A_ScriptFullPath% ; use own source code
<lang AutoHotkey>LetterFreq(Var) {
FileRead, FileText, %OpenFile%
Loop, 26
{
StringReplace StrReplace(Var, junk, FileText, % Chr(96+A_Index), , UseErrorLevelCount)
if Count
out .= Chr(96+A_Index) ": " ErrorLevelCount "`n"
}
return out
}
 
MsgBox % out</lang>
var := "The dog jumped over the lazy fox"
{{out}} (using script's own file):
var2 := "foo bar"
Msgbox, % LetterFreq(var)
Msgbox, % LetterFreq(var2)</lang>
{{out}}
<pre>
a: 61
xd: 52
e: 244
yf: 01
g: 1
h: 2
j: 1
l: 1
m: 1
o: 3
p: 1
r: 1
t: 2
u: 1
v: 1
x: 1
y: 1
z: 1
---------------------------
---------------------------
a: 1
b: 1
cf: 61
do: 42
zr: 01</pre>
e: 24
[several lines omitted]
x: 5
y: 0
z: 0</pre>
 
=={{header|AutoIt}}==