[Haskell-beginners] map increases length of list

Henk-Jan van Tuyl hjgtuyl at chello.nl
Wed Jun 17 17:58:52 EDT 2009


On Wed, 17 Jun 2009 23:35:23 +0200, Aaron MacDonald <aaronjm at eastlink.ca>  
wrote:

>
> This is how I'm calling map overall:
> -----
>  > map degreesToRadians [0,60..359]
> [0.0,1.0471975511965976,2.0943951023931953,3.141592653589793,4.1887902047863905,5.235987755982989,6.283185307179586 
> ]
> -----
>
> As you can hopefully see, there are seven elements instead of six.  
> Getting the length confirms this:
> -----
>  > length [0,60..359]
> 6
>  > length $ map degreesToRadians [0,60..359]
> 7
> -----

Enumeration works differently for Double:
   Prelude> [0, 60..359 :: Double]
   [0.0,60.0,120.0,180.0,240.0,300.0,360.0]
   Prelude> length [0, 60..359 :: Double]
   7


-- 
Met vriendelijke groet,
Henk-Jan van Tuyl


--
http://functor.bamikanarie.com
http://Van.Tuyl.eu/
--




More information about the Beginners mailing list