Daily Archives:January 2nd, 2007

How to find happiness, and achieve justice

I’ve written before about some of the great talks available online from the TED conference. Here are a couple I’ve just watched, and would definitely recommend:

  • Dan Gilbert talks about what really makes us happy, and the research that shows how bad we are at predicting what really makes us happy.
  • Oxford Statistician Peter Donnelly explores the common mistakes humans make in interpreting statistics, and the devastating impact these errors can have on the outcome of criminal trials.

Both good stuff. And the wonderful thing about having a Mac Mini sitting under my TV as a PVR is that I can use iTunes to subscribe to the RSS feeds of things like this and watch them from the comfort of my sofa…


Paul Bissex has a lovely example of the power of Python – a Quicksort implementation in 99 bytes.

>>> q=lambda s:s if len(s)<2 else q([x for x in s[1:]if x<s [0]])+[s[0]]+q([x for x in s[1:]if x>=s[0]])
>>> print q([9,7,5,3,1,8,6,4,2])
[1, 2, 3, 4, 5, 6, 7, 8, 9]

If you unwrap it to make it a bit more readable, it’s doing this:

q=lambda s:
   s if len(s)<2 
      q( [ x for x in s[1:] if x<s[0] ] )
     +[ s[0] ]
     +q( [ x for x in s[1:] if x>=s[0] ] )

Very nice! Needs Python 2.5. If you don’t know the Quicksort algorithm, here’s how it works.

In which we serve…

2007 is starting in an interesting way for me – with jury service.

I can’t, of course, say anything to anybody about the cases I may be involved with, but I can still communicate with the outside world thanks to the 3G connection on my phone, at least while I’m in the jury lounge waiting to be called.

I wonder if this is the first blog entry to be posted from within Cambridge Crown Court?

© Copyright Quentin Stafford-Fraser