[Haskell-beginners] map increases length of list

Aaron MacDonald aaronjm at eastlink.ca
Wed Jun 17 19:33:37 EDT 2009


Sigh.

Well, what I was trying to do was get all angles in the range [0, 360)  
that have 60 degrees between them, since I'm going to be working with  
hexagons.  I figured I'd use a range instead of hard-coded angles in  
case I wanted to use other shapes.

Thanks,

Aaron

On 17-Jun-09, at 6:58 PM, Henk-Jan van Tuyl wrote:

> 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