Letter frequency: Difference between revisions

Content deleted Content added
Petelomax (talk | contribs)
m →‎{{header|Phix}}: output ten per line
Line 1,372: Line 1,372:


=={{header|AutoHotkey}}==
=={{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
Loop, 26
{
{
StringReplace, junk, FileText, % Chr(96+A_Index),, UseErrorLevel
StrReplace(Var, Chr(96+A_Index), , Count)
if Count
out .= Chr(96+A_Index) ": " ErrorLevel "`n"
out .= Chr(96+A_Index) ": " Count "`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>
<pre>
a: 6
a: 1
d: 2
e: 4
f: 1
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
b: 1
c: 6
f: 1
d: 4
o: 2
r: 1</pre>
e: 24
[several lines omitted]
x: 5
y: 0
z: 0</pre>


=={{header|AutoIt}}==
=={{header|AutoIt}}==