Re: How to extract functions from a list and call them with any argument?

*To*: mathgroup at smc.vnet.net*Subject*: [mg65951] Re: [mg65919] How to extract functions from a list and call them with any argument?*From*: "David Park" <djmp at earthlink.net>*Date*: Mon, 24 Apr 2006 06:02:07 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

Dom, Your list is a list of algebraic expressions and not a list of functions. To obtain a list of functions use the Mathematica Function or pure function construction. (Look up Function in Help.) funclist = {Sin, #^3 &, Cos[#]^2}; funclist[[1]][t] Sin[t] Notice that the t came at the end of the calling expression. You could turn you original list into functions with the following statement. {Sin[x], x^3, Cos[x]^2} Function /@ (% /. x -> #) giving... {Sin[x], x^3, Cos[x]^2} {Sin[#1] & , #1^3 & , Cos[#1]^2 & } If the last statement is confusing, look up Map and ReplaceAll in Help. Also notice that the two forms of the first, Sin, function are equivalent. David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: dmp55 at sympatico.ca [mailto:dmp55 at sympatico.ca] To: mathgroup at smc.vnet.net I have a list of functions, i.e., funclist = {Sin[x], x^3, Cos[x]^2}. I can extract each of the functions, like In[1]:=funclist[[1]] Out[1]=Sin[x] , but I don't know how to call these functions with a general argument. If I type In[2]:=funclist[t][[1]] , I get Out[2]=t instead of Sin[t] (or t^3 or Cos[t]^2) What I would like is to extract a function from the list and to call it with any argument, as it was defined in a standard way: f[x_]:=Sin[x]. Dom