<div dir="ltr">Aaron,<br><br>Look at the following snippet:<br><br>> length ([0,60..359] :: [Double])<br>7<br><br>Basically, the Enum instance for Double is done differently than for Int (I don't remember why exactly). If you take off the type signature, it uses Int by default. When you use map, it implicitly converts that to a Double.<br>
<br>Hope that helps.<br><br>Michael<br><br><div class="gmail_quote">On Thu, Jun 18, 2009 at 12:35 AM, Aaron MacDonald <span dir="ltr"><<a href="mailto:aaronjm@eastlink.ca">aaronjm@eastlink.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
For some reason, the map function returns a list that has one more element than my input list.<br>
<br>
My input list is a range defined by [0, 60..359] (should translate into [0,60,120,180,240,300]).<br>
<br>
The function I'm giving to map is defined this way:<br>
-----<br>
degreesToRadians :: Double -> Double<br>
degreesToRadians degrees = degrees * (pi / 180)<br>
-----<br>
<br>
This is how I'm calling map overall:<br>
-----<br>
> map degreesToRadians [0,60..359]<br>
[0.0,1.0471975511965976,2.0943951023931953,3.141592653589793,4.1887902047863905,5.235987755982989,6.283185307179586]<br>
-----<br>
<br>
As you can hopefully see, there are seven elements instead of six. Getting the length confirms this:<br>
-----<br>
> length [0,60..359]<br>
6<br>
> length $ map degreesToRadians [0,60..359]<br>
7<br>
-----<br>
<br>
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.<br>
<br>
P.S. Is there a built-in function to convert degrees to radians and vice-versa?<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
</blockquote></div><br></div>