is it possible to do quicksort of a list with only one passing?

前端 未结 3 528
梦谈多话
梦谈多话 2020-11-29 12:00

I am learning haskell and the function definition I see is:

quickSort (x : xs) = (quickSort less) ++ (x : equal) ++ (quickSort more)
                 where         


        
3条回答
  •  隐瞒了意图╮
    2020-11-29 12:22

    It does not seem to improve anything but:

    qs (x:xs) = let (a,b) = partition (< x) xs in (qs a) ++ [x] ++ (qs b)
    

提交回复
热议问题