Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

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

Search the Archive

Re: Is there ToNumber?


On 06/14/2011 05:13 AM, SigmundV wrote:
> I had imagined that applying Real to the string would make it a
> number, e.g. Real@@"1.2", but it doesn't work:
>
> In[1]:= Head[Real @@ "1.2"]
>
> Out[1]= String
>
> Of course ToExpression works as intented:
>
> In[2]:= Head[ToExpression@"1.2"]
>
> Out[2]= Real
>
> Why can't I simply change the head of a string by using Apply?

Same reason one cannot change the head of an Integer. They are atomic.

http://www.great-quotes.com/quote/1727982

In[3]:= Apply[Integer,1.0]

Out[3]= 1.

Moreover, even if String was not atomic an type, there is neither 
documentation nor functionality to suggest Real converts input to real 
numbers.

Daniel Lichtblau
Wolfram Research


  • Prev by Date: Simple Plot3D
  • Next by Date: Sorting into bins
  • Previous by thread: Re: Is there ToNumber?
  • Next by thread: Re: Is there ToNumber?