
I'm working through "The craft of functional programming" , and I've come to excercise 3.14: "Give a function to return the average of three integers". My attempt at an answer is: averageThree :: Int -> Int -> Int -> Float averageThree a b c = fromInt(a + b + c) / 3 but when I try to load this file I get an error, "Undefined variable fromInt". I get the error on winHugs version Nov 2003 and on Hugs version Nov 2003 (in both cases in Hugs mode). Curiously, when I found a machine with an old (2002) version of Hugs on it the file loaded fine. Has something changed between versions of Hugs, is my code reasonable, and how /do/ I convert an Int to a Float in Hugs version Nov 2003? Thanks in advance, -- Tim Rowe

The function fromInt is no longer around. Use fromIntegral instead,
which works with Int and Integer.
On 4/28/05, Tim Rowe
I'm working through "The craft of functional programming" , and I've come to excercise 3.14: "Give a function to return the average of three integers".
My attempt at an answer is:
averageThree :: Int -> Int -> Int -> Float averageThree a b c = fromInt(a + b + c) / 3
but when I try to load this file I get an error, "Undefined variable fromInt".
I get the error on winHugs version Nov 2003 and on Hugs version Nov 2003 (in both cases in Hugs mode). Curiously, when I found a machine with an old (2002) version of Hugs on it the file loaded fine.
Has something changed between versions of Hugs, is my code reasonable, and how /do/ I convert an Int to a Float in Hugs version Nov 2003?
Thanks in advance,
-- Tim Rowe _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (2)
-
Cale Gibbard
-
Tim Rowe