Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- prop1 & 2 & 3 & 4, but not prop5
  2. dodgySort4 [] = []
  3. dodgySort4 [x] = [x]
  4. dodgySort4 (x:xs) = sortedList
  5.   where
  6.     list :: [Int]
  7.     replacedList :: [Int]
  8.     sortedList :: [Int]
  9.     list = insertionSort (x:xs)
  10.     replacedList = replaceDups list
  11.     sortedList = insertionSort replacedList
  12.    
  13.    
  14. -- replace duplicates with a random number
  15. replaceDups :: [Int] -> [Int]
  16. replaceDups [] = []
  17. replaceDups [x] = [x]
  18. replaceDups (x1:x2:xs)
  19.   | x1 == x2 = replaceDups ([x1] ++ [500] ++ xs)
  20.   | otherwise = x1 : replaceDups (x2:xs)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement