articles icon indicating copy to clipboard operation
articles copied to clipboard

zipWith question: Correctness of optimized Polygon Eq

Open TysonMN opened this issue 3 years ago • 0 comments

This is a question about your zipWith article.

You conclude your article by saying that this is a more efficient implementation of Eq for Polygon.

(==) :: Polygon -> Polygon -> Bool
Polygon p1Edges@(edge1:_) == Polygon p2Edges
  = let p2Edges' = rotateUntil (== edge1) p2Edges
    in p1Edges == p2Edges'

I am not convinced. If the polygons have nothing in common, then I expect rotateUntil executes forever.

Am I correct?

TysonMN avatar Aug 08 '22 11:08 TysonMN