Sfoglia il codice sorgente

Create the point data structure and distance function

DricomDragon 5 anni fa
parent
commit
35f1d8d5d4
1 ha cambiato i file con 6 aggiunte e 0 eliminazioni
  1. 6 0
      geometry.hs

+ 6 - 0
geometry.hs

@@ -0,0 +1,6 @@
+data Point = Point Float Float
+
+distance p1 p2 = 
+	let (Point a b) = p1 in
+		let (Point c d) = p2 in
+			sqrt ((a - c) * (a - c) + (b - d) * (b - d))