MathGroup Archive 2005

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

Search the Archive

Re: Converting Strings to Ints.

Use the function ToExpression.

1) These are your data

In[1]:= in = {"12223", "11313", "2424"}

Out[1]= {"12223", "11313", "2424"}

Check that the input is not numbers

In[8]:= NumberQ /@ in

Out[8]= {False, False, False}

2) Now transform to numbers (the list as a whole)

In[9]:= in2number = ToExpression[in]

Out[9]= {12223, 11313, 2424}

... and check

In[7]:= NumberQ /@ in2number

Out[7]= {True, True, True}


Chrisantha wrote:

> Dear All,
> 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?
> Yours Ever and Merry Christmas,
> Chrisantha

  • Prev by Date: What we from 1^Infinity, Infinity^0, and similar stuff
  • Next by Date: Re: Taking either a sequence or a list
  • Previous by thread: Re: Converting Strings to Ints.
  • Next by thread: problems with memory usage