chapter 3 of fp in scala exercises