Browse Source

Fix code formatting

Piotr Orzechowski 4 years ago
parent
commit
ed61d73a88
1 changed files with 14 additions and 19 deletions
  1. 14
    19
      ch03/02ex12.hs

+ 14
- 19
ch03/02ex12.hs View File

@@ -49,26 +49,21 @@ sortByCoord points = sortBy (sort) points
49 49
 
50 50
 
51 51
 sortByAngle :: [Point] -> [Point]
52
-sortByAngle points =
53
-    case points of
54
-        [] ->
55
-            []
56
-        
57
-        (p:pts) ->
58
-            p : sortBy (sort) pts
52
+sortByAngle []         = []
53
+sortByAngle (p:points) = p : sortBy (sort) points
54
+    where
55
+        sort a b
56
+            | tanA < tanB           = LT
57
+            | tanA > tanB           = GT
58
+            | distanceA < distanceB = LT
59
+            | distanceA > distanceB = GT
60
+            | otherwise = EQ
59 61
             where
60
-                sort a b
61
-                    | tanA < tanB           = LT
62
-                    | tanA > tanB           = GT
63
-                    | distanceA < distanceB = LT
64
-                    | distanceA > distanceB = GT
65
-                    | otherwise = EQ
66
-                    where
67
-                        tanA = atan2 (snd a - snd p) (fst a - fst p)
68
-                        tanB = atan2 (snd b - snd p) (fst b - fst p)
69
-                        distanceA = distance p a
70
-                        distanceB = distance p b
71
-                        distance a b = sqrt (((fst b - fst a) ^ 2) + ((snd b - snd a) ^ 2))
62
+                tanA = atan2 (snd a - snd p) (fst a - fst p)
63
+                tanB = atan2 (snd b - snd p) (fst b - fst p)
64
+                distanceA = distance p a
65
+                distanceB = distance p b
66
+                distance a b = sqrt (((fst b - fst a) ^ 2) + ((snd b - snd a) ^ 2))
72 67
 
73 68
 
74 69
 grahamScan :: [Point] -> [Point]

Loading…
Cancel
Save