finished conversion of bk 2 chapter 5 examples to Swift