ex4.1 - flatMap with pattern matching implementation. Not sure how you'd implement flatMap() without pattern matching