[Haskell-cafe] New New newbie question/help

Jules Bean jules at jellybean.co.uk
Thu Jun 28 12:04:29 EDT 2007

Paul Hudak wrote:
> As an aside, looking at your code a bit closer, I see this:
>     (polygon [(x,y),(a,b),(x,y)]))
>         where
>             b = y + side * sin(pi/3)
>             a = x + side * cos(pi/3) 
> Something is not right here -- you repeat (x,y) as a vertex.  Probably 
> the third vertex should be (x+side,y).  Also, note that sin (pi/3) and 
> cos (pi/3) are constants (namely 0.866... and 0.5, resp.).

Constant they may be, but it's still clearer in my opinion to write them 
like that. To factor them out as constants (except simply as an exercise 
in the practise of code refactoring) smacks of premature optimization to me.


More information about the Haskell-Cafe mailing list