Hi! I'm kind of new to functional programming with Haskell, I'm reading a
university course you see. Now I'm having some problems with one of our lab
assignments, we're supposed to write a program handling numeric operations
(addition, multiplication, and some functionality like sin and cos).

I've made a data type;
data Expr = Num Double | Add Expr Expr | Mul Expr Expr...

I.e for representing the expression:
2.4 * (4.0 + 1.5)
The Haskell representation is:
Mul (Num 2.4) (Add (Num 4.0) (Num 1.5))

My problem is to convert a String to an expression like the one above.
I.e the String: "2.4*(4.0+1.5)"

If we would use plain Integers there would not be a problem, since the
Prelude function 'digitToInt' :: Char -> Int does nearly what I would like
to do. But I'm stuck on the Doubles! How can I solve this in a smooth way?
-- 
View this message in context: 
http://www.nabble.com/Converting-Double-from-String-tf4586633.html#a13092415
Sent from the Haskell - Haskell mailing list archive at Nabble.com.

_______________________________________________
Haskell mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to