« Return to Thread: foild function for expressions

Re: foild function for expressions

by Carlo Vivari :: Rate this Message:

Reply to Author | View in Thread


Brent Yorgey wrote:
One comment: it looks like (add exp1 exp2), (and exp1 exp2) and so on above
are not correct.  The second argument of foldExp is a value of type Exp, so
you are pattern-matching on the constructors of Exp, and constructors are
always uppercase.  Perhaps Exp has constructors named Add, And, and so on?
Then you would want to do something like
Yepp, it's my fault I wasn't too precise in my explanation.
There's a declaration of the data type EXP,  which is not difficult to gess with the things I've said:

data Exp = LitI Int
               |LitB Bool
               |Add Exp Exp
               |And Exp Exp
               |If Exp Exp Exp

I'm going to read carefully all of your answer now (thanks to all!!!), and then I'll tell you. ;)

 « Return to Thread: foild function for expressions