[erlang-questions] Second order function lists:map

Franco Milicchio <>
Tue Mar 10 16:44:57 CET 2009


On Mar 10, 2009, at 4:24pm, Rob Charlton wrote:

> Is this what you are after?
>
> paa(A) ->
>   fun(L) ->
>           lists:map(fun(F)->
>                             F(A)
>                     end, L)
>   end.
>
> 7> G = test:paa(42).
> #Fun<test.0.118673008>
> 8> G([fun math:sin/1, fun math:cos/1, fun math:tan/1]).
> [-0.916522,-0.399985,2.29139]
>


Rob, thanks for your answer!

Actually, I was looking for the other way around:

G = test:paa([fun math:sin/1, fun math:cos/1, fun math:tan/1]).

G(0.5).


Thanks!

-- 
Franco Milicchio <>

DIA - Dept. of Computer Science and Engineering
University Roma Tre
http://plm.dia.uniroma3.it/milicchio/

-------------- 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/5c8814ac/attachment.bin>


More information about the erlang-questions mailing list