[erlang-questions] how to make the comprehension work
Richard A. O'Keefe
ok@REDACTED
Tue Aug 18 05:11:05 CEST 2015
On 18/08/2015, at 5:14 am, Roelof Wobben <r.wobben@REDACTED> wrote:
> Hello,
>
> I try to extract the modules names from the output of code:loaded_all.
>
> So I tried this :
>
> -module(module).
>
> -export([most_used_function_name/0]).
>
> most_used_function_name() ->
> process_module_data(code:all_loaded()).
>
> process_module_data(Loaded_modules) ->
> Module_list = get_modules_name(Loaded_modules).
>
> get_modules_name(Loaded_Modules_list) ->
> [ModuleList || [{ModuleList, _}] <- Loaded_Modules_List ].
>
>
>
> but now I see a message that ModuleList is unbound.
Are you *sure* that's the message you got?
It looks to me as if you have
Loaded_Modules_list in the arguments
^ lower case "l"
Loaded_Modules_List in the body
^ upper case "L"
Also, the elements of code:all_loaded() are tuples (with 2 elements),
NOT lists of tuples, and the first element is a module NAME, not any
kind of module List, so the whole thing reduces to
[Name || {Name,_} <- code:all_loaded]
2> [Name || {Name,_} <- code:all_loaded()].
[io,erl_distribution,edlin,zlib,error_handler,io_lib,
prim_eval,filename,erts_internal,unicode,orddict,gb_sets,
inet_db,inet,ordsets,group,gen,erl_scan,kernel,erl_eval,
prim_file,ets,lists,sets,inet_udp,io_lib_pretty,code,
ram_file,dict|...]
More information about the erlang-questions
mailing list