On Tue, Nov 09, 1999 at 03:54:00PM +1300, Richard A. O'Keefe wrote:
> Luis Manuel O.Soares wrote:
> > Is there any function that takes a String as an argument and returns a
> > numeral??
> 
> Andy Gill wrote: 
>    There is no built in function that does what you want.
> 
> But there _is_ a built in function that does what he _asked for_.
> If s is a string of the form
>     - zero or more layout characters
>     - optional sign
>     - one or more digits
>     - zero or more layout characters
> then  read s  will do the job perfectly.  Example:
> 
>     % hugs
>     -- banner deleted
>     Prelude> (read " -2 ") :: Int
>     -2
> 

There's also digitToInt in the Char library (which operates on individual
characters). Numeric also has a bunch of different read* functions (readInt,
readDec, readHex etc). On that note, how come there's no showOct or showHex?
Or am I missing?

-- 
-Simon Raahauge DeSantis

Reply via email to