> ERROR "U:\slav\FP\Avg.hs":11 - Type error in application > *** Expression : accum list / length list > *** Term : accum list > *** Type : Float > *** Does not match : Int > > Why "accum list" should match to "Int"? > When I try to replace (length list) with number - it works.
length :: [a] -> Int -- this is your problem use genericLength :: Num k => [a] -> k instead > ================================ > my_avg list = (accum list) / 5 --works fine > ================================ This works because '5' is translated to 'fromInteger 5', which can be a Float as desired. > xx = 5 > my_avg list = (accum list) / xx --doesn't work > -- same message as above This doesn't work because defaulting occurs and xx is given type Integer. -- Hal Daume III | [EMAIL PROTECTED] "Arrest this man, he talks in maths." | www.isi.edu/~hdaume _______________________________________________ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe