On Thu, Jun 18, 2009 at 12:35 AM, Aaron MacDonald
<aaronjm@eastlink.ca> wrote:
For some reason, the map function returns a list that has one more element than my input list.
My input list is a range defined by [0, 60..359] (should translate into [0,60,120,180,240,300]).
The function I'm giving to map is defined this way:
-----
degreesToRadians :: Double -> Double
degreesToRadians degrees = degrees * (pi / 180)
-----
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
-----
I do not seem to get this behaviour with the length if I either substitute the degreesToRadians function or substitute the [0,60..359] range.
P.S. Is there a built-in function to convert degrees to radians and vice-versa?
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners