Explorar o código

Implement the perimeter function

DricomDragon %!s(int64=5) %!d(string=hai) anos
pai
achega
d3e6558eb6
Modificáronse 1 ficheiros con 2 adicións e 2 borrados
  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)