<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>Thank you very much Jedai ... this looks much more concise and does not contain the repetitions that I had. I'd need to go over it more to understand it better.<br>I'll ping you if I have any questions about this.<br><br>Regards,<br>Kashyap<br></div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><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> Chaddaï Fouché &lt;chaddai.fouche@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> haskell-cafe@haskell.org<br><b><span style="font-weight: bold;">Sent:</span></b> Tuesday, July 28, 2009
 7:10:38 PM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [Haskell-cafe] Need feedback on my Haskell code<br></font><br>On Tue, Jul 28, 2009 at 3: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; Hi Everyone,<br>&gt; I managed to write up the line drawing function using the following links -<br>&gt; <a href="http://www.cs.helsinki.fi/group/goa/mallinnus/lines/bresenh.html" target="_blank">http://www.cs.helsinki.fi/group/goa/mallinnus/lines/bresenh.html</a><br>&gt; <a href="http://rosettacode.org/wiki/Bresenham%27s_line_algorithm#Haskell" target="_blank">http://rosettacode.org/wiki/Bresenham%27s_line_algorithm#Haskell</a><br>&gt;<br><br>I tried to simplify your function a little bit :<br><br>line :: Point -&gt; Point -&gt; [Point]<br>line pa@(xa,ya) pb@(xb,yb) = map maySwitch . unfoldr go $ (x1,y1,0)<br>&nbsp; where<br>&nbsp; &nbsp; steep = abs (yb
 - ya) &gt; abs (xb - xa)<br>&nbsp; &nbsp; maySwitch = if steep then (\(x,y) -&gt; (y,x)) else id<br>&nbsp; &nbsp; [(x1,y1),(x2,y2)] = sort [maySwitch pa, maySwitch pb]<br>&nbsp; &nbsp; deltax = x2 - x1<br>&nbsp; &nbsp; deltay = abs (y2 - y1)<br>&nbsp; &nbsp; ystep = if y1 &lt; y2 then 1 else -1<br>&nbsp; &nbsp; go (xTemp, yTemp, error)<br>&nbsp; &nbsp; &nbsp; &nbsp; | xTemp &gt; x2 = Nothing<br>&nbsp; &nbsp; &nbsp; &nbsp; | otherwise&nbsp; = Just ((xTemp, yTemp), (xTemp + 1, newY, newError))<br>&nbsp; &nbsp; &nbsp; &nbsp; where<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tempError = error + deltay<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (newY, newError) = if (2*tempError) &gt;= deltax<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  then (yTemp+ystep,tempError-deltax)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  else (yTemp,tempError)<br><br>I think it
 will be a bit better, tell me what you think ?<br><br>-- <br>Jedaï<br></div></div></div><br>



      </body></html>