[erlang-questions] Why does this happen?

Brent McConnell emcconne@REDACTED
Sun Jun 3 04:41:39 CEST 2007


I am new to Erlang and have been playing in the shell.  I have some behavior
that seems odd when importing the lists module and wanted to ask a more
knowledgeable audience why it does this.  In the first few lines I define a
list and a function, import lists and then map the function.  I then clear
variables and start again but this time I import lists before defining the
function and it fails.  Why?

8> f().
ok
9> X=[1,2,3,4].
[1,2,3,4]
10> Y=fun(Z)->Z*Z end.
#Fun<erl_eval.6.56006484>
11> Y(2).
4
12> Y(4).
16
13> import (lists).
ok
14> lists:map(Y,X).
[1,4,9,16]
15> f().
ok
16> import (lists).
ok
17> X=[1,2,3,4].
[1,2,3,4]
18> Y=fun(Z)->Z*Z end.

=ERROR REPORT==== 3-Jun-2007::02:31:08 ===
Error in process <0.45.0> with exit value:
{badarg,[{erlang,atom_to_list,[{module,lists}]},{erl_lint,'-unused_vars/3-fun-0-',2},{orddict,filter,2},{orddict,filter,2},{erl_lint,unused_vars,3},{erl_lint,check_unused_vars,3},{erl_lint,fun_clause,3},{erl_lint,'-fun_clauses/3-fun-0-'...


** exited: {badarg,[{erlang,atom_to_list,[{module,lists}]},
                    {erl_lint,'-unused_vars/3-fun-0-',2},
                    {orddict,filter,2},
                    {orddict,filter,2},
                    {erl_lint,unused_vars,3},
                    {erl_lint,check_unused_vars,3},
                    {erl_lint,fun_clause,3},
                    {erl_lint,'-fun_clauses/3-fun-0-',3}]} **
19>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070603/9c928539/attachment.htm>


More information about the erlang-questions mailing list