Map function in Erlang

advertisements

In addition to having the map function available with many arities (up to 4), Prolog allows you (under certain circumstances) to map a multiple arity function onto a single list. Say you want to test whether 'x' is a member of multiple lists. You can do:

maplist(member(x),[[a,b,c,x],[3,f,s,x]]).

The first argument of member is included, and the whole thing is mapped onto the list.

Question 1: Is something similar available to Erlang? I can't find it in the documentation, but then again I can't find it in any Prolog documentation either.

Question 2: How to use map (and similar functions) with multiple arities? Roll your own?

Thanks.


Maybe something like:

23> lists:map(fun(L) -> lists:member(42,L) end, [[1,5,8,4],[13,42],[7,2,10]]).
[false,true,false]
24>