Implement ch2.4.2's examples