I have been trying Hugs98
 
This is the average of floats list calculation program:
 
================================
accum :: [Float] -> Float
accum list = foldr (+) 0 list
 
my_avg list =  (accum list) / (length list)
================================
 
While loading it I got the compiler message:
 
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.
 
================================
my_avg list =  (accum list) / 5 --works fine
================================
xx = 5
my_avg list =  (accum list) / xx --doesn't work
-- same message as above
================================
 
Possibly, I don't know something important, or Hugs is not quite mature?
 
Thank you.
Slav.
 

Attachment: tech.gif
Description: Binary data

_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to