Exercise 1.24 in Common Lisp