Re: Applying multiple functions to multiple sets of arguements
- To: mathgroup at smc.vnet.net
- Subject: [mg42646] Re: Applying multiple functions to multiple sets of arguements
- From: bobhanlon at aol.com (Bob Hanlon)
- Date: Sat, 19 Jul 2003 03:19:30 -0400 (EDT)
- References: <bf8f5g$5ne$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
fncs = {f1, f2, f3, f4}; args = {x1, x2, x3}; Outer[#1[#2]&, fncs, args] {{f1[x1], f1[x2], f1[x3]}, {f2[x1], f2[x2], f2[x3]}, {f3[x1], f3[x2], f3[x3]}, {f4[x1], f4[x2], f4[x3]}} Bob Hanlon In article <bf8f5g$5ne$1 at smc.vnet.net>, rishiroy at umich.edu (Rishi Roy) wrote: << I was hoping someone cold help me. I wanted a way to apply an arbitrary number of functions to an arbitrary number of sets of arguments. Meaning if I have n functions: {f1, f2, ...,fn} and m sets of arguments: {x1, x2, ..., xm}, how can I generate a list like: {{f1[x1], f1[x2], ...,f1[xm]},{f2[x1], f2[x2], ...,f2[xm]},...,{fn[x1], fn[x2], ...,fn[xm]}}? I am currently doing this by looping throgh both lists and populating each results one by one. As expecting this is horribly slow. I was hoping someone could recommend a faster, functional way to do this. I tried using map, but couldnt get a handle on it.