Programming Pearls problem 1.4