Dumb guy needs help

Max Vasin max-appolo at mail.ru
Mon Apr 3 10:13:01 EDT 2006

>>>>> "Davey" == Davey dude <forceddragon at hotmail.co.uk> writes:

Davey> Im new to Haskell, hugs in particular, and was hoping you could
Davey> help me solve a problem. It should be pretty easy.  I have to
Davey> use hugs to create an expression "data Exp = Plus Exp Exp| Sub
Davey> Exp Exp| Mult Exp Exp| Power Exp Exp | Number [Int]" to define
Davey> a constant "ex1 :: Exp" that represents the function ((3*4) +
Davey> (2*(12^2))) - 2. Exp is an expression where numbers are
Davey> represented by a list of digits (540 is [5,4,0]). Got any
Davey> ideas. Any help is greatly needed!

Expression ((3*4) + (2*(12^2))) - 2 consists of 2 subexpressions:
((3*4) + (2*(12^2))) and 2 connected by the `-' operator, so

ex1 = Sub ex1_2 2

where ex1_2 is an Exp representing ((3*4) + (2*(12^2))) which is
a sum (Plus .....).

Max Vasin.

More information about the Glasgow-haskell-users mailing list