ソースを参照

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)