I have to admit that I didn’t fully understand the apfelmus example code. Nevertheless, I made an effort to address both of his criticisms:
- The merge() function does not use an accumulator argument any more and is indeed much simpler now.
- The recursive
mergesort_
function now does not use the haskell listlength
operator any more. Instead, the length of the list to be sorted is passed down the recursive chain.
Please see the optimised mergesort implementation for details.
These improvements reduced the RAM utilisation and improved the run-time performance by another 20% respectively.
Nothing to scoff at, eh?
