chapter 12 exercise 12-7: add iterators to Str