Practising scala examples from "Programming in Scala - 2nd Ed."