Guest User

Untitled

a guest
Oct 21st, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. sortByCoTan :: [Point] -> [Point]
  2. sortByCoTan [] = []
  3. sortByCoTan [a] = [a]
  4. sortByCoTan (a:as) = a : sortByFirst (sortByCoTan as) where
  5. sortByFirst [b] = [b]
  6. sortByFirst (b:c:cs)
  7. | (myCoTan a b)>= (myCoTan ac) = b : sortByFirst (c:cs)
  8. | otherwise = c : sortByFirst (b:cs)
  9. where
  10. myCoTan :: Point -> Point -> Double
  11. myCoTan p1 p2 = (pointXval p2 - pointXval p1) /
  12. (pointYval p2 - pointYval p1)
Add Comment
Please, Sign In to add comment