Reputation: 71
So I'm trying to create a bad sort function which, given a list, sorts it while deleting duplicates, and then pads the beginning of the list with "0s" to make sure the length of the badly sorted new list is the same as the size of the original list.
This is my code:
dodgySort4 xs = (replicate ((length xs) - (length (badQuick xs)) 0) : badQuick xs
where
badQuick [] = []
badQuick (x:xs) = (badQuick lesser) ++ [x] ++ (badQuick greater)
where
lesser = filter (< x) xs
greater = filter (> x) xs
However, I keep getting the "parse error on input ‘where’" error at the beginning of the first where and I'm not quite sure what the problem is?
Upvotes: 1
Views: 2075
Reputation: 3818
This is not about where
, )
is not matched in replicate
. The type is also mismatched, change :
to ++
fix the issue.
dodgySort4 :: (Ord a, Num a) => [a] -> [a]
dodgySort4 xs = (replicate ((length xs) - (length (badQuick xs))) 0) ++ badQuick xs
where ...
Upvotes: 3