[Haskell-beginners] '/' instead use 'DIV'. why?

amindfv at gmail.com amindfv at gmail.com
Fri Apr 17 19:42:46 UTC 2020


It might help to imagine if you flip your arguments:

length [23, 34, 45] / 6 :: Int

How do you represent 3/6 as an Int?

> El 17 abr 2020, a las 03:19, Alexander Chen <alexander at chenjia.nl> escribió:
> 
> Hi, 
> 
> 
> Prelude> :t (/)
> (/) :: Fractional a => a -> a -> a
> 
> Prelude> :t div
> div :: Integral a => a -> a -> a
> 
> 
> Prelude> 6 / length [23,34,45]
> error 
> 
> Prelude> 6 / 3
> 2.0
> 
> Could somebody explain to me why this is?
> 
> thanks,
> 
> Alexander Chen
> 
> 
> 
> _______________________________________________
> 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/20200417/d0c6cc1f/attachment.html>


More information about the Beginners mailing list