Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Convert from String to variable

  • To: mathgroup at
  • Subject: [mg70229] Convert from String to variable
  • From: "PengYu.UT at" <PengYu.UT at>
  • Date: Sun, 8 Oct 2006 02:04:42 -0400 (EDT)

I want generate some code like below.

{a[0][0][0] -> a000, a[0][0][1] -> a001,
   a[0][0][2] -> a002, a[0][1][0] -> a010,
   a[0][1][1] -> a011, a[0][1][2] -> a012,
   a[0][2][0] -> a020, a[0][2][1] -> a021,
   a[0][2][2] -> a022, a[1][0][0] -> a100,
   a[1][0][1] -> a101, a[1][0][2] -> a102,
   a[1][1][0] -> a110, a[1][1][1] -> a111,
   a[1][1][2] -> a112, a[1][2][0] -> a120,
   a[1][2][1] -> a121, a[1][2][2] -> a122,
   a[2][0][0] -> a200, a[2][0][1] -> a201,
   a[2][0][2] -> a202, a[2][1][0] -> a210,
   a[2][1][1] -> a211, a[2][1][2] -> a212,
   a[2][2][0] -> a220, a[2][2][1] -> a221, a[2][2][2] -> a222}

I'm looking for an automated way to generate the assignments for
a[i][j][k] (i = 1...n,j=1...n,k=1...n).

One way that I think of is
Flatten[ Table[a[i][j][k] -> "a" <> ToString[i] <> ToString[j] <>
ToString[k], {i, 0, 2}, {j, 0, 2}, {k, 0, 2}]].

But this method requires to convert the strings to variables. Is it
possible to do this in Mathematica?

Are there any better solution to generate the assignment list?


  • Prev by Date: Re: FoourierTransform of a function defined in sections
  • Next by Date: Formal operations with vectors and scalars
  • Previous by thread: Show results of Runge-Kutta Solution
  • Next by thread: Re: Convert from String to variable