Re: mathematica question
- To: mathgroup at smc.vnet.net
- Subject: [mg9218] Re: [mg9199] mathematica question
- From: seanross at worldnet.att.net
- Date: Fri, 24 Oct 1997 01:00:32 -0400
- Sender: owner-wri-mathgroup at wolfram.com
Tom wrote: > > Hello Mathematica users, > > I have a question that I hope someone has an answer for. I think it > should be simple but I cannot find a way to make it work. > > I have a set of functions that take no inputs, they are called q1[], > q2[], q3[] and so on. > > How can I get Mathematica to run the correct function given a list of > numbers as input. IE, if I supply the list {1,4,7,8} I would want > Mathematica to run the functions q1[], q4[], q7[] and q8[], assuming > they were defined. > > I would appreciate any assistance you might have with this!! > > Sincerely, > > Tom De Vries ToExpression[string] is the command you want. You can use string manipulation to make up the correct function name, then convert the string to a mathematica expression. Something like q[n_Integer]:=Evaluate[ToExpression["q"<>ToString[n]<>"[]"]]