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?
badQuick
is really bad, it loses all values that are equal tox
, e.g.badQuick [1,1,1,1,1,1,1]
will be[1]
. – Zeta