Parcourir la source

Create shape and perimeter prototype

DricomDragon il y a 5 ans
Parent
commit
1a972574fc
1 fichiers modifiés avec 7 ajouts et 0 suppressions
  1. 7 0
      geometry.hs

+ 7 - 0
geometry.hs

@@ -1,6 +1,13 @@
 data Point = Point Float Float
 
+data Shape = Singularity Point | Circle Float Point | Square Point Point
+
 distance p1 p2 = 
 	let (Point a b) = p1 in
 		let (Point c d) = p2 in
 			sqrt ((a - c) * (a - c) + (b - d) * (b - d))
+
+perimeter sh = case sh of
+	Singularity _ -> 0.0
+	Circle _ _ -> 1.0
+	Square _ _ -> 2.0