MathGroup Archive 2010

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

Search the Archive

Re: Convert string list to number list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg106618] Re: Convert string list to number list
  • From: Raffy <raffy at mac.com>
  • Date: Mon, 18 Jan 2010 05:40:12 -0500 (EST)
  • References: <hj12ud$b9u$1@smc.vnet.net>

On Jan 17, 11:34 pm, Canopus56 <canopu... at yahoo.com> wrote:
> On importing a space delimited text file,  I have an extracted list of 
zero-padded two-digit integers in the form: Amylist{"00", "01", "02", "03",
 "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"}  How do I convert these to 
real numbers or integers? Thanks - Kurt  I have reviewed the Mathematica 
documentation and a few books looking for the equivalent of a simple string-to-number function like vba's "Value".  Could not find an answer. Thanks .      

ToExpression[list] will work.

Or you could implement a stricter version:

Replace[
 Characters[list] /. Table[ToString[i] -> i, {i, 0, 9}],
 {valid : {__Integer} :> FromDigits[valid], _ -> $Failed},
 {1}
]


  • Prev by Date: Re: Contour integral around z_infinity != negative around origin
  • Next by Date: Re: Hessian Matrix of a Numerical Defined Function
  • Previous by thread: Convert string list to number list
  • Next by thread: Re: Convert string list to number list