Show 40 post(s) from this thread on one page
Page 2 of 5 First 1234 ... Last
• 11-21-2008, 07:07 PM
scarface
i am using WinHugs - haskell 98 interpreter
• 11-21-2008, 08:41 PM
Twey
Ah, I see. GHC is the de-facto standard nowadays for real development (Yhc is used a lot for research) and it includes the Data.Function module. I guess you'll have to define it yourself:
Code:

```on :: (b -> b -> c) -> (a -> b) -> a -> a -> c (g `on` f) x y = f x `g` f y```
• 11-23-2008, 10:24 PM
scarface
hi, its me again with a question. I have a function
Code:

```multAdd :: Expr -> Integer multAdd (Plus(Mult(Const x)(Const y))(Const z)) = (x * y) + z```
which multiplies 2 integers and adds a third integer to the result.
eg multAdd (Plus(Mult(Const 2)(Const 4))(Const 5)) gives 13. What i am being asked to do is make a "better" function of type
Code:

`[(Variable, Integer)]-> Expr -> Integer`
that does the same as my multAdd function with the only difference being i have to specify what a and b are (that comes from the [(Variable, Integer)] part) at the beginning.eg [("a", 3)("b", 4")] (Plus(Mult(Var "a")(Var "b"))(Const 1)).The part that confuses me is how can i make hugs know that Var "a" = 3 and Var "b" = 4. I guess some sort of pattern matching should be done?I am on the right track?
• 11-24-2008, 02:07 AM
Twey
Not necessarily. I point you in the direction of the Prelude function `lookup :: (Eq a) => a -> [(a, b)] -> Maybe b`.
• 11-25-2008, 09:30 AM
razgriz21
• 11-25-2008, 10:05 PM
scarface
i just cant seem to get my head round this haskell language.. i have been doing reading on internet but it is still confusing..so i am trying to get help from somewhere :)
• 11-26-2008, 07:40 AM
Twey
I'm interested to know from whence this exercise comes. I met someone on #haskell yesterday who seemed to be doing the same exercise, but who lived on a different continent.
• 11-26-2008, 09:53 AM
razgriz21
That might of been me, is that the haskell chat on mibbit? Im finding this really confusing scarface lol, you seem to have got the jist of it though, im still a newb lol :eek:
• 11-26-2008, 10:14 AM
Twey
No, a Russian. The exercise was given to them by their teacher as part of a worksheet, so I'm curious as to whence it originated.
• 11-26-2008, 04:32 PM
scarface
well this is a coursework we have been given for a functional programming module we are doing. i study in london. if some1 in russia is doing same exercise then maybe teachers have some source from where they get the coursework exercises and stuff. and i am a newbie as well when it comes to haskell razgriz21.so its not just you :)..
Show 40 post(s) from this thread on one page
Page 2 of 5 First 1234 ... Last