0
$\begingroup$

I'm trying to append filenames with Mathematica, and cannot do it. The output of my calculation are two lists : X and Y, calculated for a varying parameter G.

So I want to have X0, Y0 for G = 0, X0.5, Y0.5 for G = 0.5, etc. In python, I would just automate this by defining X"$G", Y"$G", and do a loop on G.

Is there an equivalent in Mathematica?

$\endgroup$
3
  • $\begingroup$ Take a look at StringJoin and ToString. $\endgroup$
    – Szabolcs
    Mar 15, 2013 at 17:18
  • $\begingroup$ Also see this. $\endgroup$
    – Jens
    Mar 15, 2013 at 17:41
  • $\begingroup$ The title talks about file names, but the question itself never mentions any I/O operation. I'm confused. $\endgroup$
    – m_goldberg
    Mar 15, 2013 at 18:25

1 Answer 1

2
$\begingroup$

Not sure exactly what you are looking for, but you can deal with strings quite nicely in Mathematica. For instance, say you have x="this" and y="that" and you want to write ten files that are numbered consectutively. You might create

 fileNames=Table[StringJoin[x, y, ToString[i]], {i, 1, 10}]

which gives you a list of 10 file names. Of course you can build the names up any way you wish.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.