defmodule WordCount do
def run do
System.argv
|> path
|> file
|> size
|> count
|> IO.puts
end
def path(filename) do
filename
|> Path.expand
end
def file(filepath) do
{:ok, text} = File.read(filepath)
text
end
def size(text) do
text |> String.length
end
def count(length) do
length / 20
end
end
WordCount.run