Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- prop1 & 2 & 3 & 4, but not prop5
- dodgySort4 [] = []
- dodgySort4 [x] = [x]
- dodgySort4 (x:xs) = sortedList
- where
- list :: [Int]
- replacedList :: [Int]
- sortedList :: [Int]
- list = insertionSort (x:xs)
- replacedList = replaceDups list
- sortedList = insertionSort replacedList
- -- replace duplicates with a random number
- replaceDups :: [Int] -> [Int]
- replaceDups [] = []
- replaceDups [x] = [x]
- replaceDups (x1:x2:xs)
- | x1 == x2 = replaceDups ([x1] ++ [500] ++ xs)
- | otherwise = x1 : replaceDups (x2:xs)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement