
28 Apr
2005
28 Apr
'05
11:13 a.m.
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