On 5 June 2011 22:17, Benjamin Edwards <span dir="ltr">&lt;<a href="mailto:edwards.benj@gmail.com">edwards.benj@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div><div><br></div><div><div>grahamScan points = scan (sort points)</div>

<div>            -- For each point, it is determined whether moving from the two previously considered points to this point is a &quot;left turn&quot; or a &quot;right turn&quot;. If it is a &quot;right turn&quot;, this means that the second-to-last point is not part of the convex hull and should be removed from consideration. This process is continued for as long as the set of the last three points is a &quot;right turn&quot;. As soon as a &quot;left turn&quot; is encountered, the algorithm moves on to the next point in the sorted array. (If at any stage the three points are collinear, one may opt either to discard or to report it, since in some applications it is required to find all points on the boundary of the convex hull.)</div>

<div>    where   scan (a : (b : (c : points)))</div><div>                | (direction a b c) == TurnRight    = scan (a : (c : points))</div><div>                | otherwise                         = a : (scan (b : (c : points)))</div>

<div>            scan (a : (b : []))                     = []</div></div></div></div></div></blockquote></div><br></div><div>What error message do you get? I loaded this code into ghci verbatim (modulo a module declaration) and it worked fine, no errors. However the definitions don&#39;t seem to be quite right. Consider any set of 3 non-linear points. Trivially the convex hull of that set is the set itself. Look at what your function scan does for a set of three points. It only returns 2, which can&#39;t be right.</div>
</blockquote><div><br></div><div>Actually make that one point. </div></div><br>