ex 3.51, 3.52 (all sicp code)