MathGroup Archive 1996

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Question: Applying a list of funcs to a list of expressions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg2937] Re: [mg2924] Question: Applying a list of funcs to a list of expressions
  • From: Rick Muirhead <muirhead at dirac.phys.washington.edu>
  • Date: Sat, 13 Jan 1996 03:20:17 -0500


In[1]:=

funcs = {f1,f2,f3,f4};
vals  = {val1,val2,val3,val4};

  Map[#[[1]][#[[2]]]&,Transpose[{funcs,vals}]]


Out[1]=

   {f1[val1],f2[val2],f3[val3],f4[val4]}

So, the "one liner" above will, I think, do what you want, but it's 
hardly eloquent, and far from transparant. I suspect that Mma has a 
cleaner build in function that, used appropriately, will do a cleaner job 
here.  I await the wisdom of the group.


Rick Muirhead
UW Physics
muirhead at phys.washington.edu



On Thu, 11 Jan 1996, David Rosky wrote:

> 
> I would like to specify a list of functions such as:
> 
> funcs = {f1, f2, f3}
> 
> and a list of values to which the functions will be
> applied:
> 
> vals = {val1, val2, val3}
> 
> I would then like to apply to each function to each corresponding value
> respectively to obtain the following list:
> 
> DesiredOutputList = {f1[val1], f2[val2], f3[val3]}
> 
> Thanks in advance,
> 
> --David
> ------------------ groskyd at gv.ssi1.com ------------------
> 

==== [MESSAGE SEPARATOR] ====


  • Prev by Date: Re: Question: Applying a list of funcs to a list of expressions
  • Next by Date: Re: Question: Applying a list of funcs to a list of expressions
  • Previous by thread: Re: Question: Applying a list of funcs to a list of expressions
  • Next by thread: Re: Question: Applying a list of funcs to a list of expressions