Code from the book The Seasoned Schemer