2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,11 +1,9 @@
|
|||
file = hd(System.argv)
|
||||
|
||||
case File.read(file) do
|
||||
{:ok, binary} -> String.upcase(binary)
|
||||
|> String.codepoints
|
||||
|> Enum.filter(fn c -> c =~ ~r/[A-Z]/ end)
|
||||
|> 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} #{v}" end)
|
||||
{:error, reason} -> IO.inspect reason
|
||||
end
|
||||
File.read!(file)
|
||||
|> String.upcase
|
||||
|> String.graphemes
|
||||
|> Enum.filter(fn c -> c =~ ~r/[A-Z]/ end)
|
||||
|> Enum.reduce(Map.new, fn c,acc -> Map.update(acc, c, 1, &(&1+1)) end)
|
||||
|> Enum.sort_by(fn {_k,v} -> -v end)
|
||||
|> Enum.each(fn {k,v} -> IO.puts "#{k} #{v}" end)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue