[erlang-questions] Second order function lists:map

Franco Milicchio franco.milicchio@REDACTED
Thu Mar 12 09:59:12 CET 2009


On Mar 10, 2009, at 11:42pm, Richard O'Keefe wrote:

>
> 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?



Now I see! Thanks to all of you, you're really handy!

Cheers!

-- 
Franco Milicchio <franco.milicchio@REDACTED>

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/20090312/a8913906/attachment.bin>


More information about the erlang-questions mailing list