MathGroup Archive 2005

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

Search the Archive

RE: Converting Strings to Ints.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg63295] RE: [mg63277] Converting Strings to Ints.
  • From: "David Annetts" <davidannetts at aapt.net.au>
  • Date: Fri, 23 Dec 2005 05:08:22 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Chrisantha,

> I have a list of strings representing numbers, i.e. a = 
> {"12223","11313","2424"} that I generated in XML and read 
> into mathematica. How do I convert this into a list of integers?

The easiest way is ToExpression, whence

	l = {"12223", "11313", "2424"}
	i = ToExpression@l

You can convince yourself that it works via

	Head@First@l
	Head@First@i

This will fail if your strings are in exponential format (it's easy to see
why!)

Regards,

Dave.


  • Prev by Date: Re: Converting Strings to Ints.
  • Next by Date: Re: Gray's Differential Geometry error?
  • Previous by thread: Re: Converting Strings to Ints.
  • Next by thread: Matrices with Mathematica 5.1