Scala: map operation, function to each of the elements of a collection