An earlier version had this, and basic structs too. It was only a little longer, at least in line count, but harder to figure out. It took me four evenings with a printout and a red pen before I was satisfied with my understanding.
(I have mixed feelings about this code: it has both good ideas and pointless obscurity. I guess the newer version would've taken me 'only' three evenings.)