A more 'Haskelly' solution for exercises 51, 52

Or at least I hope it is... Looks cool though.