소스 검색

Create the point data structure and distance function

DricomDragon 5 년 전
부모
커밋
35f1d8d5d4
1개의 변경된 파일6개의 추가작업 그리고 0개의 파일을 삭제
  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))