A comment containing a worked example of this code would be really useful.  I worked through it on paper, but it would be good not to have to do so.