[erlang-questions] passing a function to lists:map

Bob Ippolito <>
Mon Mar 22 12:55:04 CET 2010


atomize(List) -> lists:map(fun ta/1, List).

On Mon, Mar 22, 2010 at 7:49 AM, Martin DeMello <> wrote:
> ta(X) when is_list(X)    -> list_to_atom(X);
> ta(X) when is_tuple(X)   -> tuple_to_list(X);
> ta(X) when is_integer(X) -> X.
>
> % this doesn't work
> atomize(List) -> lists:map(ta, List).
>
> % this does
> atomize(List) -> lists:map(fun(X) -> ta(X) end, List).
>
> What's the difference? Have I just got the syntax wrong, or is there
> some fundamental reason I need the second version?
>
> martin
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:
>
>


More information about the erlang-questions mailing list