Lennart wrote:
> I thought Haskell 1.3 allowed "2" as a valid Float for read.
> What implementation are you using?
Our hbc compiler will indeed provide a `read' function that parses strings like
"2" as Floats but our Hugs (1.3) and ghc (2.01) won't. In any case, input like
"foo" will still cause the program to blow up at run-time. I ended up
supplying the following definition:
> atof:: String -> Maybe Float
> atof str =
> case span isDigit str of
> (_,"") -> Just (read (str++".0"))
> (_,'.':f_str) | all isDigit f_str -> Just (read str)
> _ -> Nothing
Chris Dornan [EMAIL PROTECTED]
University College Cork +353 21 902837