implement exercises 11-12 from "FP in Scala" book, chapter 5