exercise 2.3/2.5, for 2.4 and 2.6, see sicp notes on my blog