How do you do an in-place quicksort in Haskell

前端 未结 4 2041
旧巷少年郎
旧巷少年郎 2020-12-24 15:09

Could somebody provide an in-place quicksort haskell function? I.e. it returns a new sorted list, but the input list is copied to a mutable array or something.

I wan

4条回答
  •  天命终不由人
    2020-12-24 15:36

    Check out this code, it has a quick sort version that uses arrays from IO module. You can adapt it to your needs. Keep in mind though that imperative programming in Haskell can give you headaches if you are not careful (mine programs usually suffered from huge memory use and 90% time spent in garbage collection).

提交回复
热议问题