Skip to content

Instantly share code, notes, and snippets.

@edubkendo
Created August 20, 2015 04:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edubkendo/feff3c50fbc8a5c4bbfd to your computer and use it in GitHub Desktop.
Save edubkendo/feff3c50fbc8a5c4bbfd to your computer and use it in GitHub Desktop.
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
@edubkendo
Copy link
Author

Usage

$ elixir word_count.exs ~/Dropbox/leyline.txt

@edubkendo
Copy link
Author

Should clarify, this is for getting a wordcount from the scripts of Japanese games one has played while taking part in the Read More or Die 多読 contest .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment