An implementation of Practice Problem 9.