Exercise 1.31 in Common Lisp