
23 Apr
2009
23 Apr
'09
2:17 p.m.
On 23 Apr 2009, at 15:52, Daniel Carrera wrote:
Daniel Fischer wrote:
Try explicitly converting the length to the appropriate type: average xs = sum xs / fromIntegral (length xs)
Thanks. Could you help me understand what's happening?
1. length returns Int. 2. sum returns Num. 3. (/) wants Fractional.
It looks like (/) is happy with Num but doesn't like Int. This surprises me. I would have thought that Fractional is a kind of Num and Int is a kind of Fractional
Int isn't a Fractional because it can't represent fractional numbers. Bob