<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Unless the exercise requires you to output in fun/arity format, that isn’t required in order to simply sort and count the elements in the list of lists you have below.</div><div class=""><br class=""></div><div class="">-Rick</div><div class=""><br class=""></div><div class="">P.S. I’m not suggesting the following code is the best way to do this, nor that lists should be used over binaries, but here’s one way to the conversion assuming it is required for the exercise (here I’m using the sorted list of exported functions from the “inet” module as an example):</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class="">12> [lists:flatten(io_lib:format("~s/~s", [atom_to_list(Fun), integer_to_list(Arity)])) || {Fun,Arity} <- lists:keysort(1, inet:module_info(exports))].</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class="">["close/1","connect_options/2","fdopen/6","format_error/1",</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class=""> "get_rc/0","getaddr/3","getaddr/2","getaddr_tm/3",</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class=""> "getaddrs/2","getaddrs/3","getaddrs_tm/3","getfd/1",</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class=""> "gethostbyaddr/1","gethostbyaddr/2","gethostbyaddr_tm/2",</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class=""> "gethostbyname/2","gethostbyname/3","gethostbyname/1",</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class=""> "gethostbyname_self/2","gethostbyname_string/2",</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class=""> "gethostbyname_tm/3","gethostname/1","gethostname/0",</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class=""> "getif/0","getif/1","getifaddrs/1","getifaddrs/0",</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class=""> "getiflist/1",</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class=""> [...]|…]</div></div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class=""><br class=""></div><div class="">suggesting</div><div class="">Now if you are just going to output the resulting list using something like io:format/2, then you don’t even need to lists:flatten/1:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class="">15> io:format([io_lib:format("~s/~s\n", [atom_to_list(Fun), integer_to_list(Arity)]) || {Fun,Arity} <- lists:keysort(1, inet:module_info(exports))]).</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class="">close/1</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class="">connect_options/2</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class="">fdopen/6</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class="">format_error/1</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class="">get_rc/0</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class="">getaddr/3</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class="">getaddr/2</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class="">getaddr_tm/3</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class="">getaddrs/2</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class="">getaddrs/3</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class="">getaddrs_tm/3</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class="">getfd/1</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class="">gethostbyaddr/1</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class="">gethostbyaddr/2</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class="">gethostbyaddr_tm/2</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class="">gethostbyname/2</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class="">gethostbyname/3</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class="">gethostbyname/1</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class="">gethostbyname_self/2</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class="">gethostbyname_string/2</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class="">gethostbyname_tm/3</div><div style="margin: 0px; font-size: 14px; font-family: Menlo;" class="">gethostname/1</div></div><div class="">…</div><div class="">...</div><div class=""><br class=""><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Aug 18, 2015, at 1:13 PM, Roelof Wobben <<a href="mailto:r.wobben@home.nl" class="">r.wobben@home.nl</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">Hello,<br class=""><br class="">Im still trying to solve exercise 2 of chapter 8 of Programming erlang.<br class=""><br class="">Now I succeed in finding all functions that are exported by a module.<br class=""><br class="">I see now this output :<br class=""><br class="">[{get_rc,0}, {close,1}, {peername,1}, {setpeername,2}, {peernames,...}, {...}|...], [{module,2},{module_info,0},{module_info,1}], [{new,0},{is_set,1},{size,...},{...}|...], [{server,3},{interfaces,...},{...}|...], [{init_it,...},{...}|...], [{...}|...], [...]|...]<br class=""><br class="">So I have list which are containing more list which contains one of more tuples<br class=""><br class="">Is it possible to convert this to for example [get_rc/0, peername/1, peernames/? , module/2 ]<br class=""><br class="">I tried with lists:flatten( name_of_list) but that one do not give me the right output.<br class=""><br class="">I need the nice output because I have to sort them and then count them.<br class=""><br class="">Roelof<br class=""><br class=""><br class="">---<br class="">Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware.<br class=""><a href="https://www.avast.com/antivirus" class="">https://www.avast.com/antivirus</a><br class=""><br class="">_______________________________________________<br class="">erlang-questions mailing list<br class="">erlang-questions@erlang.org<br class="">http://erlang.org/mailman/listinfo/erlang-questions<br class=""></div></blockquote></div><br class=""></div></div></body></html>