scala exercise in List operation