[Haskell-cafe] Dividing integers?

Ferenc Wagner wferi at afavant.elte.hu
Thu Mar 18 15:08:41 EST 2004


"Matias Hernandez" <matiash at artech.com.uy> writes:

> I mean, apparently "/" is not defined for integers but I
> don't know how to "cast" the result of the length function
> into a Double...
>
> Prelude> (length [1,2]) / 3

Prelude> fromIntegral (length [1,2])/3
0.666666666666667

> Prelude> 2 / 3
> 0.6666666666666666

Literal 2 means fromIntegral 2, but length::[a]->Int.
-- 
Feri.


More information about the Haskell-Cafe mailing list