2-pivot quicksort
This posting on the Java core library mailing list proposes to replace the current quicksort with a new, 2-pivot quicksort.
Ordinary quicksort in Haskell looks something like this:
quicksort [] = []
quicksort (pivot:rest) =
quicksort [x| x ← rest, x ≤ pivot] ++
[pivot] ++
quicksort [x| x ← rest, [...]
So, I thought it would be a fun idea for my first ever Lisp/Scheme program to implement Alan Turing’s original a-machines from his paper, On Computable Numbers, with an Application to the Entscheidungsproblem (paper available to public). Fun? Oh, I hadn’t any idea…
Preamble; choice of implementation
I decided to go with the latest and greatest version [...]
¶
Posted 10 August 2009
† Porges
§
code
‡
°
Also tagged: code, debugging, ikarus, machine, Programming, recursion, scheme, silly, theory, turing, universal, ypsilon
Just a small tip on this: When you add an argument to a function that already exists you should check the existing usage of the function. Say you have this:
f x y z = …
… and you want:
f x y z w = …
First of all you should check the contexts where f is used. [...]
Looking through the list of predefined (or, in Microsoft’s parlance, standard) query operators defined in C# 3.0, there is one that stands out as missing: the ‘map’ function. However, with the new query expression syntax, this is trivial to define:
public static IEnumerable<T> Map<F,T>(Func<F,T> func, IEnumerable<F> source)
{
return
[...]