 Wafer_Thin_Ham Super Spammer

Joined: 18 Nov 2005 Karma :    
|
 Posted: 12:24 - 23 Nov 2007 Post subject: Haskell Programmers?? |
 |
|
I'm trying to do some work in Haskell for uni.
we need to take a list of ints and a single int, then return an expression formed from the list of ints to make the int. So for example:
[2, 1] 3
2+1 = 3
Except of any length and only using + - / *. THe numbers in the list must be 1 and up, and can only be whole numbers.
I've defined the Expression and a way to display it, but I can't get the evaluation function to work.
It can only work if the numbers are always whole and it never goes into negative numbers.
At the moment it gives the
"Need instance of integral(maybe int) to define value" error, and I can't get around it.
Anyway for me to get around this without using the M2 thingey would be greatly appreiated. I think it has something to do with maybe and mapmaybe, but I'm not sure.
See attached code.
Thanks
Chris ____________________ My Flickr |
|