[Haskell-cafe] An Haskell implementation of a sweep line algorithm for the detection of segments intersection
Henning Thielemann
lemming at henning-thielemann.de
Tue Dec 7 21:14:29 CET 2010
On Mon, 6 Dec 2010, vince vegga wrote:
> Hi,
>
> Here is my Haskell implementation of the Shamos and Hoey algorithm for
> detecting segments intersection in the plane:
>
> http://neonstorm242.blogspot.com/2010/12/sweep-line-algorithm-for-detection
> -of.html
>
> I'm new to Haskell, so any useful comments will be appreciated.
In sweepLine, things like
| a = False
| otherwise = x
can be written as (not a && x) and
if a then True else x
as (a || x).
In handleLeftEndpoint you can create (events,updateLine) outside the case
analysis, since this is common to all cases.
In general you can find hints in:
http://www.haskell.org/haskellwiki/Haskell_programming_tips
and in
http://www.haskell.org/haskellwiki/Category:Style
More information about the Haskell-Cafe
mailing list