[erlang-questions] How can I make a list of this

Steve Davis steven.charles.davis@REDACTED
Wed Aug 19 01:39:57 CEST 2015

Hi Roelof,

Here you go:

1> [[{sorted, lists:sort(X)}, {count, length(X)}] || X <- [inet:module_info(exports)]].
2> [get_rc/0].                                                    
** exception error: an error occurred when evaluating an arithmetic expression
     in operator  '/'/2
        called as get_rc / 0

What the book/lesson is trying to teach is probably not how to do basic operations on lists (which is notionally the point of the exercise). It’s actually trying to get you to reach for the right tool to do the job by getting you to explore the platform libraries and the power of the platform for yourself.

Yes, I cheated above and used a comprehension above to present the answers you want, and also showed what happens when you get what you originally asked for. Likely you didn’t learn much from that, since what I typed in was born of spending time with the libraries and knowing what to do with a problem I’m presented with and understanding what erlang tells you when you get it “wrong".

You need to be patient and find your own solutions to things, since if you are merely taking others’ solutions, you will never become a “power user”. It’s a hard slog, I don’t deny that.

However, the REPL, particularly in your early learning lets you try things out instantly, and is invaluable help in breaking down a problem. You can try individual steps extremely easily - and in a way that is simply not possible with non-functional languages.

If it’s any help or encouragement, it took me months to “grok” erlang and its unfamiliar ways, but once I had, I realized what I was missing. Each day, even after a few years, I learn something new and positive about the platform. It’s also been an empowerment in my relationship to computers; I can express concepts that would be essentially intractable in many popular languages.

I wish you well in your journey (one that I have personally experienced) and offer the thought that it’s likely more rewarding, and more empowering in the long term, to sit with a problem, read the documentation that comes with Erlang (which is extremely good despite its many critics) and *find your own solution* than to look outside for help too quickly. 

Sure if you get totally stuck, there’s help here.

I can promise you that the long path and all the hard work to becoming an “erlang ninja” will be worth every second.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150818/d10765a2/attachment.htm>

More information about the erlang-questions mailing list