소스 검색

Implement the perimeter function

DricomDragon 5 년 전
부모
커밋
d3e6558eb6
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      geometry.hs

+ 2 - 2
geometry.hs

@@ -9,5 +9,5 @@ distance p1 p2 =
 
 perimeter sh = case sh of
 	Singularity _ -> 0.0
-	Circle _ _ -> 1.0
-	Square _ _ -> 2.0
+	Circle r _ -> 3.14 * 2 * r
+	Square (Point a b) (Point c d) -> 2 * abs (a - c) + 2 * abs (b - d)