Author Archives

Back in Auckland

… and looking for employment, if anyone wants to hire me

n-pivot quicksort

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, [...]

Debugging Turing: An excursion with Scheme

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 [...]

Sometimes it’s all too much…

Argh

#include <stdio.h>
#include <math.h>
#include <fenv.h>
 
int main () {
// don’t set rounding here
double ten0 = sin(pow(10.0,22));
 
fesetround(FE_DOWNWARD);
double ten1 = sin(pow(10.0,22));
 
fesetround(FE_UPWARD);
double ten2 = sin(pow(10.0,22));
 
fesetround(FE_TONEAREST);
double ten3 = sin(pow(10.0,22));
 
fesetround(FE_TOWARDZERO);
double ten4 = sin(pow(10.0,22));
 
printf(
"Default: %f\n"
"Downward: %f\n"
"Upward: %f\n"
"ToNearest: %f\n"
"TowardZero: %f\n",
ten0, ten1,
ten2, ten3, ten4);
 
return 0;
}

$ gcc test.c -lm -fno-builtin && ./a.out
Default: [...]