[erlang-questions] Second order function lists:map
Tue Mar 10 23:42:40 CET 2009
On 11 Mar 2009, at 3:56 am, Franco Milicchio wrote:
> 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 :)
1. map(F, L) -> [F(X) | X <- L].
paa(F) -> fun (L) -> map(F, L) end.
2. pam(L, X) -> [F(X) | F <- L].
aap(L) -> fun (X) -> pam(L, X) end.
See the parallels?
More information about the erlang-questions