Browse Source

Fix code formatting

master
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


sortByAngle :: [Point] -> [Point]
sortByAngle points =
case points of
[] ->
[]
(p:pts) ->
p : sortBy (sort) pts
sortByAngle [] = []
sortByAngle (p:points) = p : sortBy (sort) points
where
sort a b
| tanA < tanB = LT
| tanA > tanB = GT
| distanceA < distanceB = LT
| distanceA > distanceB = GT
| otherwise = EQ
where
sort a b
| tanA < tanB = LT
| tanA > tanB = GT
| distanceA < distanceB = LT
| distanceA > distanceB = GT
| otherwise = EQ
where
tanA = atan2 (snd a - snd p) (fst a - fst p)
tanB = atan2 (snd b - snd p) (fst b - fst p)
distanceA = distance p a
distanceB = distance p b
distance a b = sqrt (((fst b - fst a) ^ 2) + ((snd b - snd a) ^ 2))
tanA = atan2 (snd a - snd p) (fst a - fst p)
tanB = atan2 (snd b - snd p) (fst b - fst p)
distanceA = distance p a
distanceB = distance p b
distance a b = sqrt (((fst b - fst a) ^ 2) + ((snd b - snd a) ^ 2))


grahamScan :: [Point] -> [Point]

Loading…
Cancel
Save