[erlang-questions] Imported function as argument

Alex Gerdes <>
Mon Jan 27 11:24:18 CET 2014


Hello,

I recently bumped into the following issue. I expected that it was possible to use an imported function as argument in a higher-order function. For example:

-module(bla).

-compile(export_all).

-import(lists, [reverse/1, map/2]).

foo(Xss) ->
  map(fun reverse/1, Xss).

However, the compiler complains that reverse/1 is undefined:

1> c(bla).
bla.erl:8: function reverse/1 undefined
error

Is it mandatory to give the fully qualified function name for an external function when it is used as argument in a higher-order function?

Best regards,

Alex 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140127/4998f71f/attachment.html>


More information about the erlang-questions mailing list