Anonymous user
Letter frequency: Difference between revisions
→{{header|Elixir}}: File.open -> File.read
m (→{{header|zkl}}: update) |
(→{{header|Elixir}}: File.open -> File.read) |
||
Line 699:
<lang elixir>file = hd(System.argv)
case File.
{:ok, binary} -> String.upcase(binary)
|> String.codepoints
|> Enum.
|> Enum.reduce(Map.new, fn c,acc -> Dict.update(acc, c, 1, &(&1+1)) end)
|> Enum.sort_by(fn {_k,v} -> -v end)
|> Enum.each(fn {k,v} -> IO.puts "#{k}
{:error, reason} -> IO.inspect reason
end
{{out}}
<pre>
C:\Elixir>elixir letterfrequency.exs \work\unixdict.txt
E
A
I
R
T
O
N
S
L
C
U
M
D
P
H
G
B
Y
F
W
K
V
X
Z
J
Q
</pre>
|