Finish initial version of L6 parts 1-3

All here, seems to work, makes sensible output.  Needs a bit of polish,
but is relatively concise.  Probably doesn't need to contain higher-order
functions or generators, but could (if we really cared for some reason)