An old Scala homework assignment