MathGroup Archive 2003

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

Search the Archive

Re: A short question about SetDelayed[]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg42506] Re: A short question about SetDelayed[]
  • From: bobhanlon at aol.com (Bob Hanlon)
  • Date: Sat, 12 Jul 2003 05:19:07 -0400 (EDT)
  • References: <belnnp$gu3$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

The usual method is to use a pattern rather than have multiple definitions.

f[i_Integer] := g[i, x];

However,

Clear[f];

x=5; Do[ToExpression["f[i]:="<> ToString[g[i,x]]],{i,10}]

?f


Bob Hanlon

In article <belnnp$gu3$1 at smc.vnet.net>, "Vadym Kulik" <kulik_nospam at umn.edu>
wrote:

<< 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}]


  • Prev by Date: RE: Evaluation and replacement?
  • Next by Date: Movies
  • Previous by thread: Re: A short question about SetDelayed[]
  • Next by thread: RE: A short question about SetDelayed[]