Exercise 1.29 in Common Lisp