Coursiera homework. Course: Functional Programming Principles in Scala