Chapter 12 applicative: exercise 12.17