Skip to content

Instantly share code, notes, and snippets.

@AlchemistCamp
Last active July 26, 2018 07:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlchemistCamp/c37b6347606e537d0a16d68fbe6dc29d to your computer and use it in GitHub Desktop.
Save AlchemistCamp/c37b6347606e537d0a16d68fbe6dc29d to your computer and use it in GitHub Desktop.
Episode 4 source (lesson 2)
filename = IO.gets("File to count the words from: ") |> String.trim()
words =
File.read!(filename)
|> String.split(~r{(\\n|[^\w'])+})
|> Enum.filter(fn x -> x != "" end)
words |> Enum.count() |> IO.puts()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment