<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div><br></div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">Thanks David <br>Regards,<br>Kashyap<br><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><font face="Tahoma" size="2"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> david48 &lt;dav.vire+haskell@gmail.com&gt;<br><b><span style="font-weight: bold;">To:</span></b> CK Kashyap &lt;ck_kashyap@yahoo.com&gt;<br><b><span style="font-weight: bold;">Cc:</span></b> Chaddaï Fouché &lt;chaddai.fouche@gmail.com&gt;; haskell-cafe@haskell.org<br><b><span style="font-weight: bold;">Sent:</span></b> Wednesday, July 29, 2009 4:43:52 PM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [Haskell-cafe] Need feedback on my Haskell code<br></font><br>
On Wed, Jul 29, 2009 at 12:04 PM, CK Kashyap&lt;<a ymailto="mailto:ck_kashyap@yahoo.com" href="mailto:ck_kashyap@yahoo.com">ck_kashyap@yahoo.com</a>&gt; wrote:<br>&gt; map maySwitch . unfoldr go $ (x1,y1,0)<br><br>I'm not an expert and I might say things the wrong way or without the<br>required rigor, so with this disclaimer here's my explanation :<br><br>go calculates a step of the line, given the current coordinates and<br>the error value<br>it returns nothing if the line is done.<br><br>unfoldr go calculates a list of lines coordinates, keeping calling go,<br>and stopping when go returns nothing.<br><br>maySwitch takes a coordinate, and switches the x and y values<br>depending on the axis we're following<br>map maySwitch does the same for the entire list of coordinates.<br><br>when you compose the two,<br>map maySwitch . unfoldr go&nbsp; is then a function that takes initial<br>coordinates, makes a list of coordinates and may switch the x's and<br>y's
 depending on the axis we're following.<br><br><br>Now (.) takes two functions, namely map maySwitch and unfoldr go. If<br>you don't write the $, what you actually mean is<br>(map maySwitch) . ( unfoldr go (x1,y1,0))<br><br>this ( unfoldr go (x1,y1,0)) is not of the right type for (.) : it<br>should take a parameter and return a value, but here it just returns a<br>value.<br><br>so you have to find a way to give (x1,y1,0) to the whole composed<br>function&nbsp; map maySwitch . unfoldr go.<br><br>the obvious way to do it is by writing:<br><br>( map maySwitch . unfoldr go ) (x1,y1,0 )<br><br>the $ is just a more readable way to write it : since $ binds with<br>less priority, in<br>map maySwitch . unfoldr go $ (x1,y1,0)<br>what's on the right of $ will be applied to what's on the left<br><br>David.<br></div></div></div><br>



      </body></html>