Re: RE:
- To: mathgroup at smc.vnet.net
- Subject: [mg42543] Re: RE:
- From: "Vadym Kulik" <kulik_nospam at umn.edu>
- Date: Mon, 14 Jul 2003 05:42:12 -0400 (EDT)
- Organization: University of Minnesota, Twin Cities Campus
- References: <beokjb$sus$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Thank you, Hartmut! x = 6; Do[(f[#] := g[#, x]) &[i], {i, 3}] works. Vadym "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com> wrote in message news:beokjb$sus$1 at smc.vnet.net... > > >-----Original Message----- > >From: Vadym Kulik [mailto:kulik_nospam at umn.edu] To: mathgroup at smc.vnet.net > >Sent: Friday, July 11, 2003 8:58 AM > >To: mathgroup at smc.vnet.net > >Subject: > > > > > >Hi guys: > > > >I work with Mathematica for 2 weeks and now I'm really stuck with the > >following problem: > > > >I'd like to generate an array of functions by the rule > >f[i]:=g[i,x], where x > >stands for arguments some of which have been assigned > >numerical values; i is > >an index, so that f[1]:=g[1,x], etc. > > > >Unfortunately, the following code doesn't work > >x = 5; Do[f[i] := g[i, x], {i, 10}] > > > >... neithes does this > >x = 5; Do[f[i] := g[Evaluate[i], x], {i, 10}] > > > >Any help? > > > >Thanks, > >Vadym > > > > > > Vadym, > > Not clear to me, what you want to attain, is it this:... > > In[105]:= Clear[f] > In[106]:= > x = 5; Do[f[i] = g[i, x], {i, 3}] > > In[107]:= ?f > > Global`f > > f[1] = g[1, 5] > > f[2] = g[2, 5] > > f[3] = g[3, 5] > > ...or this? > > In[108]:= Clear[x, f] > In[109]:= > x = 6; Do[(f[#] := g[#, x]) &[i], {i, 3}] > > In[110]:= ?f > > Global`f > > f[1] := g[1, x] > > f[2] := g[2, x] > > f[3] := g[3, x] > > > Why not just do > > In[113]:= Clear[x, f] > In[114]:= > x = 7; > f[i_Integer /; 0 < i <= 3] := g[i, x] > > In[116]:= f[3] > Out[116]= g[3, 7] > > In[117]:= x = 8; f[2] > Out[117]= g[2, 8] > > > -- > Hartmut Wolf >