4 ms·
You can write the imperative quicksort in haskell and wrap the mutation so it can't escape. This forces you to copy of the incoming array but optimizations can
by Tarean 8y ago
You can write the imperative quicksort in haskell and wrap the mutation so it can't escape.
This forces you to copy of the incoming array but optimizations can remove intermediate copies. This is similar to r-values in c++, for instance
quicksort (fromList [10, 9..1])
would only do one allocation with optimizations.
freeze . quicksortMutable . copy . new . New.unstream $ Bundle.fromList [10,9..1]
new . modify quicksortMutable . New.unstream $ Bundle.enumFromStepN 10 (-1) 10
Also, what you posted is tree sort not quick sort.
- pmarreck 8y agoIsn't quicksort a type of tree sort? (having just googled both, but not finding said statement)