[erlang-questions] Second order function lists:map
Jeroen Koops
koops.j@REDACTED
Tue Mar 10 16:54:30 CET 2009
paa(Funs) -> fun(X) -> [ Fun(X) || Fun <- Funs] end.
??
2009/3/10 Franco Milicchio <franco.milicchio@REDACTED>
>
> 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 <franco.milicchio@REDACTED>
>
> DIA - Dept. of Computer Science and Engineering
> University Roma Tre
> http://plm.dia.uniroma3.it/milicchio/
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090310/00145f5c/attachment.htm>
More information about the erlang-questions
mailing list