This is the solution to the challenge from Lesson 2.
It's a command line utility that outputs the number of words (and optionally lines or characters) in a file. This is definitely a ridiculous project. Neither mix nor escript are used. This is a more basic approach.
Source code for this episode
5 Comments
I like your solution with flags.
Oh man I finally solved it. ;_; Only 23 lines too. Also, I didn't use the docs. I think maybe I haven't looked at enough documentation for them to have meant anything useful to me. I certainly took the hint and tried reading up on enum.each and enum.at, but what I read didn't have much meaning and I did not incorporate them into my solution. :| The above video did help, however. So thanks for talking about them a little.
Why not just use
String.length(file_content)
for character count? It matches bashwc -c
output.Also I want to point out that the assignment was not clear. I though the desired program should output count for word OR line OR chars. Not all at the same time. So therefore I was confused why do I need
Enum.each
thanks for episode