HN user

kaykay

7 karma
Posts0
Comments7
View on HN
No posts found.

There is a bug in the code, unless the input is expected to be a set instead of a list.

I believe the right implementation should be something like:

  main :: IO ()
  main = print $ quicksort [1, 123, 42, 90, 1, 23, 24, 12, 3]
  quicksort [] = []
  quicksort (x:xs) = quicksort left ++ [x] ++ quicksort right
      where left  = [ y | y <- xs, y < x ]
            right = [ y | y <- xs, y >= x ]