[Haskell-beginners] Mixed division
Ut Primum
utprimum at gmail.com
Fri Feb 5 18:28:51 UTC 2021
Hi,
when you write 3 Haskell sees it as a "num" while the type of the length
[1,2,3] is "int". So 3 and length [1,2,3] have not the same type.
Il ven 5 feb 2021, 19:23 Lawrence Bottorff <borgauf at gmail.com> ha scritto:
> I can divide a float by an integer
>
> > 2.4 / 3
> 0.7999999999999999
>
> but why can I not do this?
>
> < 2.4 / (length [1,2,3])
> <interactive>:288:1-22: error:
> * No instance for (Fractional Int) arising from a use of `/'
> * In the expression: 2.4 / (length [1, 2, 3])
>
> LB
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20210205/4d96d480/attachment.html>
More information about the Beginners
mailing list