We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 05f752d commit 80c09f6Copy full SHA for 80c09f6
word_count.exs
@@ -0,0 +1,8 @@
1
+filename = IO.gets("File to count the words from: ") |> String.trim
2
+body = File.read! filename
3
+empty = fn x -> x != "" end
4
+count = String.split(body, ~r{(\\n|[^\w'])+})
5
+ |> Enum.filter(empty)
6
+ |> Enum.count
7
+
8
+IO.puts count
0 commit comments