scala exercises (P27)