Implement ch2.2.4's examples