Some nifty functions that have come from my ongoing study of algorithms