[erlang-questions] Second order function lists:map

Franco Milicchio <>
Tue Mar 10 15:56:23 CET 2009

Hi everyone!

I am trying to write two small functions employing the lists package,  
and now I am wondering how to proceed. My functions are quite  
straightforward: I want two second-order functions that "abstract"  

The first one is a function that applies a given function to a list of  
arguments. So, a first application gives me a function, and this  
applied to a list gives me the mapping of my function over the list. I  
have succeeded in doing this function and it seems to work:

paa(F) ->
     fun(L) ->
             lists:map(F, L)

41> PP=p:paa(fun math:sin/1).

42> PP(lists:seq(0,100)).

The second one is tricky to me (I am not an erlang guru!). I want its  
"dual", so given a list of functions, I'd like to map them to a single  
argument, writing a second-order function like the above p:paa/1. The  
only problem is that I am stopped by this problem, I know it's easy  
but I am not that good at functional programming :)

Thanks for any help!

Franco Milicchio <>

DIA - Dept. of Computer Science and Engineering
University Roma Tre

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2435 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090310/8fbd7668/attachment.bin>

More information about the erlang-questions mailing list