MathGroup Archive 2006

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

Search the Archive

Re: Convert from String to variable


On 10/8/06, David Park <djmp at earthlink.net> wrote:
> Peng,
>
> Just use Symbol.
>
> Symbol["a" <> ToString[1] <> ToString[2] <> ToString[3]]
> Head[%]
> a123
> Symbol

What I really intent to define is a function like the following. l, m
and n could go from 0 to any positive integer. Here the parameter list
of CD should also be changed correspondingly.

CD[Ith_, z_, d_, Ith0_, a000_, a001_, a002_, a010_, a011_, a012_, a020_,
    a021_, a022_, a100_, a101_, a102_, a110_, a111_, a112_, a120_, a121_,
    a122_, a200_, a201_, a202_, a210_, a211_, a212_, a220_, a221_, a222_] :=
    Sum[ToExpression["a" <> ToString[l] <> ToString[m] <> ToString[n]]*(
    Ith - Ith0)^l*z^(2*m)*d^(n), {l, 0, 2}, {m, 0, 2}, {n, 0, 2}]


I tried this, but it is not working. The difficulty is in the left
hand side. Can I write a function to define a set of other functions?

CD[Ith_, z_, d_, Ith0_, Flatten@
    Table[ToExpression["a" <> ToString[l] <> ToString[m] <> ToString[n] <>
           "_"], {l, 0, 2}, {m, 0, 2}, {n, 0, 2}]] := Sum[ToExpression["a" <>
            ToString[l] <> ToString[m] <> ToString[n]]*(Ith - Ith0)^l*z^(
          2*m)*d^(n), {l, 0, 2}, {m, 0, 2}, {n, 0, 2}]


  • Prev by Date: a simple product, but with "i = 1...n AND i != x"
  • Next by Date: RE: Convert from String to variable
  • Previous by thread: Convert from String to variable
  • Next by thread: Re: Convert from String to variable