MathGroup Archive 2001

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

Search the Archive

Re: integer to string??

  • To: mathgroup at smc.vnet.net
  • Subject: [mg30955] Re: integer to string??
  • From: "Steve Luttrell" <luttrell at signal.qinetiq.com>
  • Date: Fri, 28 Sep 2001 03:55:03 -0400 (EDT)
  • Organization: Defence Evaluation & Research Agency
  • References: <9ouhp1$1b5$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

"Richard" <wzn at jongnederland.nl> wrote in message
news:9ouhp1$1b5$1 at smc.vnet.net...
> Is it possible to append an integer to a string? For example in a for-loop
> i'm trying to create the strings: file1, file2, file3, etc. How can I do
> this by appending a counter (i) to the string filee.

It is best to try avoiding the use of For loops in Mathematica, because
there are many powerful ways of operating on whole lists of objects at a
time rather than explicitly counting through the individual list elements..

In  this case you could do this:

Map["file" <> ToString[#] &, Range[3]]

which is an example of the use of the following construct

Map[function,list]

which wraps each list element in the stated function.

For your problem the list is {1,2,3}, and the function converts each element
of this list to a string, and then joins it to the end of the string "file",
thus eventually producing the list {"file1", "file2", "file3"}.

All of this is done with no loop counters.


--
Steve Luttrell
QinetiQ, Malvern, U.K.




  • Prev by Date: Re: checking for a particular value in a matrix
  • Next by Date: Re: FileName and Shell Command
  • Previous by thread: RE: integer to string??
  • Next by thread: mprep, WinMe and Viusal C/C++