MathGroup Archive 2005

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

Search the Archive

Re: Re: Applying a list of functions to a list of arguments

  • To: mathgroup at smc.vnet.net
  • Subject: [mg57444] Re: [mg57377] Re: [mg57309] Applying a list of functions to a list of arguments
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Sat, 28 May 2005 05:39:07 -0400 (EDT)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <200505260831.EAA18668@smc.vnet.net>
  • Reply-to: murray at math.umass.edu
  • Sender: owner-wri-mathgroup at wolfram.com

This problem also reminds me of a simpler one:  Given

   f = {f1, f2, f3};
   a = (* some number *)

what are nice ways of producing the following result?

   {f1[a], f2[a], f3[a]}

Th
Wolf, Hartmut wrote:
>>-----Original Message-----
>>From: D M Yates [mailto:yatesd at mac.com] 
To: mathgroup at smc.vnet.net
> 
>>Sent: Tuesday, May 24, 2005 11:13 AM
>>Subject: [mg57444] [mg57377] [mg57309] Applying a list of functions to a list of arguments
>>
>>I have a list of functions, and a list of arguments:
>>
>>For example,
>>f = {f1, f2, f3}
>>a = {a1,a2,a3}
>>
>>I would like to return
>>{f1[a1],f2[a2],f3[a3]}
>>
>>I thought this should easy, but am stumped. Obviously the lists are of 
>>equal, but arbitrary length, and the arguments may or may not 
>>be atomic 
>>expressions. In my particular case, the arguments are likely to be 
>>combinations of Real, and List[Real,...], but I hope this is 
>>irrelevant.
>>
>>Any suggestions?
>>
>>Many thanks,
>>
>>Derek Yates
>>
>>
> 
> 
> This is indeed a FAQ. 
> 
> If you like to consider your list of arguments as a list of argument
> lists (of one argument here):
> 
> In[8]:= aa = Partition[a,1]
> Out[8]= {{a1}, {a2}, {a3}}
> 
> then 
> 
> In[9]:= MapThread[Apply,{f, aa}]
> Out[9]= {f1[a1], f2[a2], f3[a3]}
> 
> 
> else 
> 
> In[10]:= MapThread[#1@#2&,{f, a}]
> Out[10]= {f1[a1], f2[a2], f3[a3]}
> 
> --
> Hartmut Wolf
> 
> 

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305


  • Prev by Date: Re: Integration under Mathematica 5.0
  • Next by Date: Re: Re: A.I for mathematica
  • Previous by thread: Re: Applying a list of functions to a list of arguments
  • Next by thread: Re: Applying a list of functions to a list of arguments